[llvm] Branch folding: Avoid infinite loop with indirect target blocks (PR #96956)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 12:37:42 PDT 2024
https://github.com/v01dXYZ created https://github.com/llvm/llvm-project/pull/96956
Tasks remaining:
- [ ] Add in the comment about EHPad it's also necessary for indirect targets.
- [ ] Add a sanity test with a timeout
>From 2bd22fbc97a78240fc3f5ec220b94c2230349c11 Mon Sep 17 00:00:00 2001
From: v01dxyz <v01dxyz at v01d.xyz>
Date: Thu, 27 Jun 2024 21:33:57 +0200
Subject: [PATCH] Branch folding: Avoid infinite loop with indirect target
blocks
---
llvm/lib/CodeGen/BranchFolding.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 55aa1d438b2a6..8182573e5f31f 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -1756,8 +1756,8 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
// possible and not remove the "!FallThrough()->isEHPad" condition below.
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());
More information about the llvm-commits
mailing list