[llvm] [BOLT][AArch64] Expand cmpbr when reversing would overflow (PR #202998)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 02:47:46 PDT 2026


================
@@ -969,7 +990,11 @@ uint64_t SimplifyConditionalTailCalls::fixTailCalls(BinaryFunction &BF) {
       uint64_t Count = 0;
       if (CondSucc != BB) {
         // Patch the new target address into the conditional branch.
-        MIB->reverseBranchCondition(*CondBranch, CalleeSymbol, Ctx);
+        InstructionListType Code =
+            MIB->reverseBranchCondition(*CondBranch, CalleeSymbol, Ctx);
+        auto II = PredBB->replaceInstruction(
+            PredBB->findInstruction(CondBranch), Code);
+        CondBranch = &*(II);
----------------
labrinea wrote:

This code is x86 only, but to make this future proof I agree we can get the last instruction from the code sequence here.

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


More information about the llvm-commits mailing list