diff options
author | Eric Christopher <echristo@apple.com> | 2011-01-22 21:17:33 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2011-01-22 21:17:33 +0000 |
commit | 08e8b3b629de18115996c63841eceb3083ac51ea (patch) | |
tree | 4aebe98062ad879e2fc83303cebf4eee457eb4ab /llvm/lib/Analysis/InlineCost.cpp | |
parent | 703d6e62d05fc1f783c09a13240c8638f47d96c6 (diff) | |
download | bcm5719-llvm-08e8b3b629de18115996c63841eceb3083ac51ea.tar.gz bcm5719-llvm-08e8b3b629de18115996c63841eceb3083ac51ea.zip |
Only apply the devirtualization bonus once instead of per-call site in the
target function.
Fixes part of rdar://8546196
llvm-svn: 124044
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index b103897977b..6e251aa2140 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/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; } |