Skip to content

Commit 264c664

Browse files
committed
[BPI] Use BasicBlock::isEHPad() to check exception handling block.
There is no need to iterate all predecessors of current block, check if current block is the invoke unwind destination of any predcessor. We can directly call `BasicBlock::isEHPad()` to check if current block is a exception handling block.
1 parent 96e8d0f commit 264c664

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)