From fb2c6bbf42b09c0d3d31df7cac3f5a6cc2ee929e Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 18 Jan 2024 23:26:22 +0800 Subject: [BranchFolding] Use isSuccessor to confirm fall through (#77923) When merging blocks, if the previous block has no any branch instruction and has one successor, the successor may be SEH landing pad and the block will always raise exception and nerver fall through to next block. We can not merge them in such case. isSuccessor should be used to confirm it can fall through to next block. --- llvm/lib/CodeGen/BranchFolding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/BranchFolding.cpp') diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 599b7c7..a9f7835 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -1411,7 +1411,7 @@ ReoptimizeBlock: // This has to check PrevBB->succ_size() because EH edges are ignored by // analyzeBranch. if (PriorCond.empty() && !PriorTBB && MBB->pred_size() == 1 && - PrevBB.succ_size() == 1 && + PrevBB.succ_size() == 1 && PrevBB.isSuccessor(MBB) && !MBB->hasAddressTaken() && !MBB->isEHPad()) { LLVM_DEBUG(dbgs() << "\nMerging into block: " << PrevBB << "From MBB: " << *MBB); -- cgit v1.1