Skip to content

Commit 5e9cba3

Browse files
committed
[MERGE #6099 @wyrichte] Fixes #5950 - While updating ByteCodeUpwardExposedUsed using bailOutOffset, when given a branching instr, do not attempt to update the branching instr's label to the next bytecode instr if the branching instr is conditional.
Merge pull request #6099 from wyrichte:build/wyrichte/br
2 parents 8e57fd6 + 9a0bee0 commit 5e9cba3

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,11 +2659,17 @@ BackwardPass::ProcessBailOutInfo(IR::Instr * instr, BailOutInfo * bailOutInfo)
26592659
BVSparse<JitArenaAllocator>* tmpBv = nullptr;
26602660
if (instr->IsBranchInstr())
26612661
{
2662-
IR::LabelInstr* target = instr->AsBranchInstr()->GetTarget();
2662+
IR::BranchInstr* branchInstr = instr->AsBranchInstr();
2663+
IR::LabelInstr* target = branchInstr->GetTarget();
26632664
uint32 targetOffset = target->GetByteCodeOffset();
2664-
if (targetOffset == instr->GetByteCodeOffset())
2665+
2666+
// If the instr's label has the same bytecode offset as the instr then move the targetOffset
2667+
// to the next bytecode instr. This condition can be true on conditional branches, ex: a
2668+
// while loop with no body (passing the loop's condition would branch the IP back to executing
2669+
// the loop's condition), in these cases do not move the targetOffset.
2670+
if (targetOffset == instr->GetByteCodeOffset() && branchInstr->IsUnconditional())
26652671
{
2666-
// This can happen if the target is an break or airlock block
2672+
// This can happen if the target is a break or airlock block.
26672673
Assert(
26682674
target->GetBasicBlock()->isAirLockBlock ||
26692675
target->GetBasicBlock()->isAirLockCompensationBlock ||
@@ -2673,11 +2679,12 @@ BackwardPass::ProcessBailOutInfo(IR::Instr * instr, BailOutInfo * bailOutInfo)
26732679
);
26742680
targetOffset = target->GetNextByteCodeInstr()->GetByteCodeOffset();
26752681
}
2676-
BVSparse<JitArenaAllocator>* branchTargetUpdwardExposed = target->m_func->GetByteCodeOffsetUses(targetOffset);
2677-
if (branchTargetUpdwardExposed)
2682+
BVSparse<JitArenaAllocator>* branchTargetUpwardExposed = target->m_func->GetByteCodeOffsetUses(targetOffset);
2683+
if (branchTargetUpwardExposed)
26782684
{
2679-
// The bailout should restore both the bailout destination and the branch target since we don't know where we'll end up
2680-
trackingByteCodeUpwardExposedUsed = tmpBv = trackingByteCodeUpwardExposedUsed->OrNew(branchTargetUpdwardExposed);
2685+
// The bailout should restore both the bailout destination and
2686+
// the branch target since we don't know where we'll end up.
2687+
trackingByteCodeUpwardExposedUsed = tmpBv = trackingByteCodeUpwardExposedUsed->OrNew(branchTargetUpwardExposed);
26812688
}
26822689
}
26832690
Assert(trackingByteCodeUpwardExposedUsed);

0 commit comments

Comments
 (0)