[llvm-branch-commits] [llvm-branch] r125261 - /llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp
Eric Christopher
echristo at apple.com
Wed Feb 9 18:59:44 PST 2011
Author: echristo
Date: Wed Feb 9 20:59:44 2011
New Revision: 125261
URL: http://llvm.org/viewvc/llvm-project?rev=125261&view=rev
Log:
Check in the "simple hack" for inlining functions with calls to functions
that will be devirtualized by the inlining. Reduce the per-function call
bonus to a single bonus per function inlined.
rdar://8546196
Modified:
llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp
Modified: llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp?rev=125261&r1=125260&r2=125261&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Analysis/InlineCost.cpp Wed Feb 9 20:59:44 2011
@@ -24,6 +24,7 @@
unsigned InlineCostAnalyzer::FunctionInfo::
CountCodeReductionForConstant(Value *V) {
unsigned Reduction = 0;
+ bool indirectCallBonus = false;
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI)
if (isa<BranchInst>(*UI) || isa<SwitchInst>(*UI)) {
// We will be able to eliminate all but one of the successors.
@@ -37,11 +38,11 @@
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
// Turning an indirect call into a direct call is a BIG win
if (CI->getCalledValue() == V)
- Reduction += InlineConstants::IndirectCallBonus;
+ indirectCallBonus = true;
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
// Turning an indirect call into a direct call is a BIG win
if (II->getCalledValue() == V)
- Reduction += InlineConstants::IndirectCallBonus;
+ indirectCallBonus = true;
} else {
// Figure out if this instruction will be removed due to simple constant
// propagation.
@@ -75,6 +76,7 @@
}
}
+ if (indirectCallBonus) Reduction += InlineConstants::IndirectCallBonus;
return Reduction;
}
More information about the llvm-branch-commits
mailing list