@@ -2659,11 +2659,17 @@ BackwardPass::ProcessBailOutInfo(IR::Instr * instr, BailOutInfo * bailOutInfo)
2659
2659
BVSparse<JitArenaAllocator>* tmpBv = nullptr ;
2660
2660
if (instr->IsBranchInstr ())
2661
2661
{
2662
- IR::LabelInstr* target = instr->AsBranchInstr ()->GetTarget ();
2662
+ IR::BranchInstr* branchInstr = instr->AsBranchInstr ();
2663
+ IR::LabelInstr* target = branchInstr->GetTarget ();
2663
2664
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 ())
2665
2671
{
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.
2667
2673
Assert (
2668
2674
target->GetBasicBlock ()->isAirLockBlock ||
2669
2675
target->GetBasicBlock ()->isAirLockCompensationBlock ||
@@ -2673,11 +2679,12 @@ BackwardPass::ProcessBailOutInfo(IR::Instr * instr, BailOutInfo * bailOutInfo)
2673
2679
);
2674
2680
targetOffset = target->GetNextByteCodeInstr ()->GetByteCodeOffset ();
2675
2681
}
2676
- BVSparse<JitArenaAllocator>* branchTargetUpdwardExposed = target->m_func ->GetByteCodeOffsetUses (targetOffset);
2677
- if (branchTargetUpdwardExposed )
2682
+ BVSparse<JitArenaAllocator>* branchTargetUpwardExposed = target->m_func ->GetByteCodeOffsetUses (targetOffset);
2683
+ if (branchTargetUpwardExposed )
2678
2684
{
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);
2681
2688
}
2682
2689
}
2683
2690
Assert (trackingByteCodeUpwardExposedUsed);
0 commit comments