diff options
| author | David Chisnall <csdavec@swan.ac.uk> | 2010-05-01 15:47:41 +0000 |
|---|---|---|
| committer | David Chisnall <csdavec@swan.ac.uk> | 2010-05-01 15:47:41 +0000 |
| commit | 453b4932465c68406fedb08fea7e4b00a399d3cc (patch) | |
| tree | 687b45384f18dd362b77e95db254d555f17fb8aa /lib/Analysis | |
| parent | c9c3d9938b7533786ed9a1736a86453d9241ce68 (diff) | |
| download | external_llvm-453b4932465c68406fedb08fea7e4b00a399d3cc.zip external_llvm-453b4932465c68406fedb08fea7e4b00a399d3cc.tar.gz external_llvm-453b4932465c68406fedb08fea7e4b00a399d3cc.tar.bz2 | |
Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called function as an explicit argument, for use when inlining function pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
| -rw-r--r-- | lib/Analysis/InlineCost.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp index b478b50..6271371 100644 --- a/lib/Analysis/InlineCost.cpp +++ b/lib/Analysis/InlineCost.cpp @@ -259,9 +259,15 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { // InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, SmallPtrSet<const Function*, 16> &NeverInline) { + return getInlineCost(CS, CS.getCalledFunction(), NeverInline); +} + +InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, + Function *Callee, + SmallPtrSet<const Function*, 16> &NeverInline) { Instruction *TheCall = CS.getInstruction(); - Function *Callee = CS.getCalledFunction(); Function *Caller = TheCall->getParent()->getParent(); + bool isDirectCall = CS.getCalledFunction() == Callee; // Don't inline functions which can be redefined at link-time to mean // something else. Don't inline functions marked noinline or call sites @@ -276,11 +282,11 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, // be inlined. This value may go negative. // int InlineCost = 0; - + // If there is only one call of the function, and it has internal linkage, // make it almost guaranteed to be inlined. // - if (Callee->hasLocalLinkage() && Callee->hasOneUse()) + if (Callee->hasLocalLinkage() && Callee->hasOneUse() && isDirectCall) InlineCost += InlineConstants::LastCallToStaticBonus; // If this function uses the coldcc calling convention, prefer not to inline |
