summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BranchProbabilityInfo.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2018-06-08 13:03:21 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2018-06-08 13:03:21 +0000
commit4d063e7bb13cc123c724a1a82a8e74aeb8804f82 (patch)
treedcfca31dc3b0a2d19846f3a434bd1eff2c4acee6 /llvm/lib/Analysis/BranchProbabilityInfo.cpp
parentb3c6f07dde8caa750e13171377bc07072f77cf22 (diff)
downloadbcm5719-llvm-4d063e7bb13cc123c724a1a82a8e74aeb8804f82.tar.gz
bcm5719-llvm-4d063e7bb13cc123c724a1a82a8e74aeb8804f82.zip
[BPI] Apply invoke heuristic before loop branch heuristic
Currently the loop branch heuristic is applied before the invoke heuristic which makes us overestimate the probability of the unwind destination of invokes inside loops. This in turn makes us grossly underestimate the frequencies of loops with invokes. Reviewed By: skatkov, vsk Differential Revision: https://reviews.llvm.org/D47371 llvm-svn: 334285
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r--llvm/lib/Analysis/BranchProbabilityInfo.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index ed4dc9031ab..1a4fc0465bb 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -203,12 +203,10 @@ BranchProbabilityInfo::updatePostDominatedByColdCall(const BasicBlock *BB) {
/// unreachable-terminated block as extremely unlikely.
bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) {
const TerminatorInst *TI = BB->getTerminator();
+ (void) TI;
assert(TI->getNumSuccessors() > 1 && "expected more than one successor!");
-
- // Return false here so that edge weights for InvokeInst could be decided
- // in calcInvokeHeuristics().
- if (isa<InvokeInst>(TI))
- return false;
+ assert(!isa<InvokeInst>(TI) &&
+ "Invokes should have already been handled by calcInvokeHeuristics");
SmallVector<unsigned, 4> UnreachableEdges;
SmallVector<unsigned, 4> ReachableEdges;
@@ -351,12 +349,10 @@ bool BranchProbabilityInfo::calcMetadataWeights(const BasicBlock *BB) {
/// Return false, otherwise.
bool BranchProbabilityInfo::calcColdCallHeuristics(const BasicBlock *BB) {
const TerminatorInst *TI = BB->getTerminator();
+ (void) TI;
assert(TI->getNumSuccessors() > 1 && "expected more than one successor!");
-
- // Return false here so that edge weights for InvokeInst could be decided
- // in calcInvokeHeuristics().
- if (isa<InvokeInst>(TI))
- return false;
+ assert(!isa<InvokeInst>(TI) &&
+ "Invokes should have already been handled by calcInvokeHeuristics");
// Determine which successors are post-dominated by a cold block.
SmallVector<unsigned, 4> ColdEdges;
@@ -975,6 +971,8 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI,
continue;
if (calcMetadataWeights(BB))
continue;
+ if (calcInvokeHeuristics(BB))
+ continue;
if (calcUnreachableHeuristics(BB))
continue;
if (calcColdCallHeuristics(BB))
@@ -987,7 +985,6 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI,
continue;
if (calcFloatingPointHeuristics(BB))
continue;
- calcInvokeHeuristics(BB);
}
PostDominatedByUnreachable.clear();
OpenPOWER on IntegriCloud