[llvm] [BOLT][AArch64] Fix error "cannot reverse branch" in LongJmp pass. (PR #186850)

Paschalis Mpeis via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 05:50:57 PDT 2026


================
@@ -818,13 +818,24 @@ void LongJmpPass::relaxLocalBranches(BinaryFunction &BF) {
         return;
       }
 
+      // If the other successor is a fall-through, invert the condition code.
+      BinaryBasicBlock *NextBB =
+          BF->getLayout().getBasicBlockAfter(BB, /*IgnoreSplits*/ false);
+      bool IsReversibleBranch = MIB->isReversibleBranch(Inst);
+      bool HasFallThrough = BB->getConditionalSuccessor(false) == NextBB;
+
+      // An additional trampoline may be needed if the branch is irreversible.
----------------
paschalis-mpeis wrote:

nit to ~ :
```suggestion
      // Add an additional fall-through trampoline to work around irreversible branches.
```

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


More information about the llvm-commits mailing list