[llvm] [BOLT] Fix local out-of-range stub issue that leads to infinite loop in LongJmp pass (PR #73918)

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 01:57:33 PST 2023


================
@@ -202,10 +202,22 @@ LongJmpPass::replaceTargetWithStub(BinaryBasicBlock &BB, MCInst &Inst,
     }
   } else if (LocalStubsIter != Stubs.end() &&
              LocalStubsIter->second.count(TgtBB)) {
-    // If we are replacing a local stub (because it is now out of range),
-    // use its target instead of creating a stub to jump to another stub
+    // The TgtBB and TgtSym now are the local out-of-range stub and its label.
+    // So, we are attempting to restore BB to its previous state without using
+    // this stub.
     TgtSym = BC.MIB->getTargetSymbol(*TgtBB->begin());
-    TgtBB = BB.getSuccessor(TgtSym, BI);
+    assert(TgtSym && "First instruction is expected to be a branch.");
----------------
yota9 wrote:

The first instruction doesn't have to be a branch. It is probably would be ADRP one for stub. More proper would be "Expected first instruction to contain a target symbol" or smth like that.

https://github.com/llvm/llvm-project/pull/73918


More information about the llvm-commits mailing list