diff options
| author | Mehdi Amini <joker.eph@gmail.com> | 2025-08-14 15:36:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 15:36:46 +0200 |
| commit | df57d6a01e85ca78da2febab21b268d9fd6955a0 (patch) | |
| tree | 19b0aab453e6bc7e2b15d3220024dfdacd4fa57e /llvm/lib/CodeGen/BranchFolding.cpp | |
| parent | df86ea61b7ed484ca797f96d7ad40fd9ada7ba30 (diff) | |
| parent | 7bda76367f19cfc19086f68d9dd5ac019a9ceccd (diff) | |
Merge branch 'main' into users/joker-eph-python-bindings-maintainersusers/joker-eph-python-bindings-maintainers
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index dcfd9aad70fc..7292bc2be0df 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -1787,10 +1787,18 @@ ReoptimizeBlock: // below were performed for EH "FallThrough" blocks. Therefore, even if // that appears not to be happening anymore, we should assume that it is // possible and not remove the "!FallThrough()->isEHPad" condition below. + // + // Similarly, the analyzeBranch call does not consider callbr, which also + // introduces the possibility of infinite rotation, as there may be + // multiple successors of PrevBB. Thus we check such case by + // FallThrough->isInlineAsmBrIndirectTarget(). + // NOTE: Checking if PrevBB contains callbr is more precise, but much + // more expensive. MachineBasicBlock *PrevTBB = nullptr, *PrevFBB = nullptr; SmallVector<MachineOperand, 4> PrevCond; - if (FallThrough != MF.end() && - !FallThrough->isEHPad() && + + if (FallThrough != MF.end() && !FallThrough->isEHPad() && + !FallThrough->isInlineAsmBrIndirectTarget() && !TII->analyzeBranch(PrevBB, PrevTBB, PrevFBB, PrevCond, true) && PrevBB.isSuccessor(&*FallThrough)) { MBB->moveAfter(&MF.back()); |
