summaryrefslogtreecommitdiff
path: root/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2011-01-22 21:17:33 +0000
committerEric Christopher <echristo@apple.com>2011-01-22 21:17:33 +0000
commit7020f12ee8cf8fbf7d5343239c52655352867ccd (patch)
treefc4bec10b87091f4c157504c1939d16505b37ed8 /lib/Analysis/InlineCost.cpp
parent8184e289db45acd0bd8bbf7087f7a1274ef55f15 (diff)
downloadllvm-7020f12ee8cf8fbf7d5343239c52655352867ccd.tar.gz
llvm-7020f12ee8cf8fbf7d5343239c52655352867ccd.tar.bz2
llvm-7020f12ee8cf8fbf7d5343239c52655352867ccd.tar.xz
Only apply the devirtualization bonus once instead of per-call site in the
target function. Fixes part of rdar://8546196 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InlineCost.cpp')
-rw-r--r--lib/Analysis/InlineCost.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp
index b103897977..6e251aa214 100644
--- a/lib/Analysis/InlineCost.cpp
+++ b/lib/Analysis/InlineCost.cpp
@@ -146,17 +146,18 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) {
// performance boost we can expect if the specified value is constant.
unsigned CodeMetrics::CountBonusForConstant(Value *V) {
unsigned Bonus = 0;
+ bool indirectCallBonus = false;
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
User *U = *UI;
if (CallInst *CI = dyn_cast<CallInst>(U)) {
// Turning an indirect call into a direct call is a BIG win
if (CI->getCalledValue() == V)
- Bonus += InlineConstants::IndirectCallBonus;
+ indirectCallBonus = true;
}
else if (InvokeInst *II = dyn_cast<InvokeInst>(U)) {
// Turning an indirect call into a direct call is a BIG win
if (II->getCalledValue() == V)
- Bonus += InlineConstants::IndirectCallBonus;
+ indirectCallBonus = true;
}
// FIXME: Eliminating conditional branches and switches should
// also yield a per-call performance boost.
@@ -187,6 +188,9 @@ unsigned CodeMetrics::CountBonusForConstant(Value *V) {
Bonus += CountBonusForConstant(&Inst);
}
}
+
+ if (indirectCallBonus) Bonus += InlineConstants::IndirectCallBonus;
+
return Bonus;
}