Skip to content

Commit 8961301

Browse files
Enna1AlexisPerry
authored andcommitted
[BPI] Use BasicBlock::isEHPad() to check exception handling block. (llvm#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.
1 parent f51870f commit 8961301

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

llvm/lib/Analysis/BranchProbabilityInfo.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,9 @@ BranchProbabilityInfo::getInitialEstimatedBlockWeight(const BasicBlock *BB) {
787787
? static_cast<uint32_t>(BlockExecWeight::NORETURN)
788788
: static_cast<uint32_t>(BlockExecWeight::UNREACHABLE);
789789

790-
// Check if the block is 'unwind' handler of some invoke instruction.
791-
for (const auto *Pred : predecessors(BB))
792-
if (Pred)
793-
if (const auto *II = dyn_cast<InvokeInst>(Pred->getTerminator()))
794-
if (II->getUnwindDest() == BB)
795-
return static_cast<uint32_t>(BlockExecWeight::UNWIND);
790+
// Check if the block is an exception handling block.
791+
if (BB->isEHPad())
792+
return static_cast<uint32_t>(BlockExecWeight::UNWIND);
796793

797794
// Check if the block contains 'cold' call.
798795
for (const auto &I : *BB)

0 commit comments

Comments
 (0)