summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BranchProbabilityInfo.cpp
diff options
context:
space:
mode:
authorJun Bum Lim <junbuml@codeaurora.org>2015-12-21 22:00:51 +0000
committerJun Bum Lim <junbuml@codeaurora.org>2015-12-21 22:00:51 +0000
commita23e5f7516cabf2fc42148687cebf454ba3f5388 (patch)
tree6979e72a6cd26d39f3807f1c01987e6d02bf7f46 /llvm/lib/Analysis/BranchProbabilityInfo.cpp
parentab361efee7c5641cd214cf64d0f3ef3c48ba21b8 (diff)
downloadbcm5719-llvm-a23e5f7516cabf2fc42148687cebf454ba3f5388.tar.gz
bcm5719-llvm-a23e5f7516cabf2fc42148687cebf454ba3f5388.zip
Enhance BranchProbabilityInfo::calcUnreachableHeuristics for InvokeInst
This is recommit of r256028 with minor fixes in unittests: CodeGen/Mips/eh.ll CodeGen/Mips/insn-zero-size-bb.ll Original commit message: When identifying blocks post-dominated by an unreachable-terminated block in BranchProbabilityInfo, consider only the edge to the normal destination block if the terminator is InvokeInst and let calcInvokeHeuristics() decide edge weights for the InvokeInst. llvm-svn: 256202
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r--llvm/lib/Analysis/BranchProbabilityInfo.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index 6cdf43a06a9..a0d6123b583 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -147,6 +147,16 @@ bool BranchProbabilityInfo::calcUnreachableHeuristics(BasicBlock *BB) {
if (TI->getNumSuccessors() == 1 || UnreachableEdges.empty())
return false;
+ // If the terminator is an InvokeInst, check only the normal destination block
+ // as the unwind edge of InvokeInst is also very unlikely taken.
+ if (auto *II = dyn_cast<InvokeInst>(TI))
+ if (PostDominatedByUnreachable.count(II->getNormalDest())) {
+ PostDominatedByUnreachable.insert(BB);
+ // Return false here so that edge weights for InvokeInst could be decided
+ // in calcInvokeHeuristics().
+ return false;
+ }
+
uint32_t UnreachableWeight =
std::max(UR_TAKEN_WEIGHT / (unsigned)UnreachableEdges.size(), MIN_WEIGHT);
for (SmallVectorImpl<unsigned>::iterator I = UnreachableEdges.begin(),
OpenPOWER on IntegriCloud