diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-29 01:02:02 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-29 01:02:02 +0000 |
commit | 1a99dbfe3b70c83d3f3e4648b5868c04697cd77c (patch) | |
tree | 41431bf4c8c53891278373226e99b42be702e01d /lib/Transforms/IPO/Inliner.cpp | |
parent | 2d5a0b9e5473618c53cca6cec1b99d18b4c9f76b (diff) | |
download | external_llvm-1a99dbfe3b70c83d3f3e4648b5868c04697cd77c.zip external_llvm-1a99dbfe3b70c83d3f3e4648b5868c04697cd77c.tar.gz external_llvm-1a99dbfe3b70c83d3f3e4648b5868c04697cd77c.tar.bz2 |
Factor shouldInline method out of Inliner.
- No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/Inliner.cpp')
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index c267272..74af183 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -72,6 +72,31 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG, } return true; } + +/// shouldInline - Return true if the inliner should attempt to inline +/// at the given CallSite. +bool Inliner::shouldInline(CallSite CS) { + int Cost = getInlineCost(CS); + float FudgeFactor = getInlineFudgeFactor(CS); + + int CurrentThreshold = InlineThreshold; + Function *Fn = CS.getCaller(); + if (Fn && !Fn->isDeclaration() + && Fn->hasFnAttr(Attribute::OptimizeForSize) + && InlineThreshold != 50) { + CurrentThreshold = 50; + } + + if (Cost >= (int)(CurrentThreshold * FudgeFactor)) { + DOUT << " NOT Inlining: cost=" << Cost + << ", Call: " << *CS.getInstruction(); + return false; + } else { + DOUT << " Inlining: cost=" << Cost + << ", Call: " << *CS.getInstruction(); + return true; + } +} bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { CallGraph &CG = getAnalysis<CallGraph>(); @@ -136,24 +161,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { // If the policy determines that we should inline this function, // try to do so. CallSite CS = CallSites[CSi]; - int InlineCost = getInlineCost(CS); - float FudgeFactor = getInlineFudgeFactor(CS); - - int CurrentThreshold = InlineThreshold; - Function *Fn = CS.getCaller(); - if (Fn && !Fn->isDeclaration() - && Fn->hasFnAttr(Attribute::OptimizeForSize) - && InlineThreshold != 50) { - CurrentThreshold = 50; - } - - if (InlineCost >= (int)(CurrentThreshold * FudgeFactor)) { - DOUT << " NOT Inlining: cost=" << InlineCost - << ", Call: " << *CS.getInstruction(); - } else { - DOUT << " Inlining: cost=" << InlineCost - << ", Call: " << *CS.getInstruction(); - + if (shouldInline(CS)) { // Attempt to inline the function... if (InlineCallIfPossible(CS, CG, SCCFunctions, getAnalysis<TargetData>())) { |