[llvm] [BPI] Use BasicBlock::isEHPad() to check exception handling block. (PR #95771)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 08:23:26 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Enna1 (Enna1)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/95771.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/BranchProbabilityInfo.cpp (+3-6)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/95771
More information about the llvm-commits
mailing list