[llvm] 8f49dab - [BPI] Use BasicBlock::isEHPad() to check exception handling block. (#95771)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 18:45:07 PDT 2024
Author: Enna1
Date: 2024-06-24T09:45:04+08:00
New Revision: 8f49dab19e861baeb0d87452e652ed97d3883d1a
URL: https://github.com/llvm/llvm-project/commit/8f49dab19e861baeb0d87452e652ed97d3883d1a
DIFF: https://github.com/llvm/llvm-project/commit/8f49dab19e861baeb0d87452e652ed97d3883d1a.diff
LOG: [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.
Added:
Modified:
llvm/lib/Analysis/BranchProbabilityInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index 50dcd5f45233f..3e9c60918f3c0 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)
More information about the llvm-commits
mailing list