aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BranchProbabilityInfo.cpp
diff options
context:
space:
mode:
authorEnna1 <xumingjie.enna1@bytedance.com>2024-06-24 09:45:04 +0800
committerGitHub <noreply@github.com>2024-06-24 09:45:04 +0800
commit8f49dab19e861baeb0d87452e652ed97d3883d1a (patch)
tree078afe04e7883768f9e9f6092354038bca8bd382 /llvm/lib/Analysis/BranchProbabilityInfo.cpp
parent905c58f5aa33f1cd6370913bcadcd2e7dd8abbd0 (diff)
downloadllvm-8f49dab19e861baeb0d87452e652ed97d3883d1a.zip
llvm-8f49dab19e861baeb0d87452e652ed97d3883d1a.tar.gz
llvm-8f49dab19e861baeb0d87452e652ed97d3883d1a.tar.bz2
[BPI] Use BasicBlock::isEHPad() to check exception handling block. (#95771)
There is no need to iterate all predecessors of current block, check if current block is the invoke unwind destination of any predecessor. We can directly call `BasicBlock::isEHPad()` to check if current block is an exception handling block.
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r--llvm/lib/Analysis/BranchProbabilityInfo.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index 50dcd5f..3e9c609 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -787,12 +787,9 @@ BranchProbabilityInfo::getInitialEstimatedBlockWeight(const BasicBlock *BB) {
? static_cast<uint32_t>(BlockExecWeight::NORETURN)
: static_cast<uint32_t>(BlockExecWeight::UNREACHABLE);
- // Check if the block is 'unwind' handler of some invoke instruction.
- for (const auto *Pred : predecessors(BB))
- if (Pred)
- if (const auto *II = dyn_cast<InvokeInst>(Pred->getTerminator()))
- if (II->getUnwindDest() == BB)
- return static_cast<uint32_t>(BlockExecWeight::UNWIND);
+ // Check if the block is an exception handling block.
+ if (BB->isEHPad())
+ return static_cast<uint32_t>(BlockExecWeight::UNWIND);
// Check if the block contains 'cold' call.
for (const auto &I : *BB)