diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-06 01:16:28 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-06 01:16:28 +0000 |
| commit | 74bb06c0f02e650ea9ec73729f41a620fc55a8ee (patch) | |
| tree | afca8ce6c36562b58ca308a8e9ac59667e982e9e /llvm/lib/Transforms | |
| parent | a10e65c852e1a4e27d57960276c6b0ef691fda71 (diff) | |
| download | bcm5719-llvm-74bb06c0f02e650ea9ec73729f41a620fc55a8ee.tar.gz bcm5719-llvm-74bb06c0f02e650ea9ec73729f41a620fc55a8ee.zip | |
Reintroduce the InlineHint function attribute.
This time it's for real! I am going to hook this up in the frontends as well.
The inliner has some experimental heuristics for dealing with the inline hint.
When given a -respect-inlinehint option, functions marked with the inline
keyword are given a threshold just above the default for -O3.
We need some experiments to determine if that is the right thing to do.
llvm-svn: 95466
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Inliner.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp index 55cc536717c..97e2f063946 100644 --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -41,6 +41,16 @@ static cl::opt<int> InlineLimit("inline-threshold", cl::Hidden, cl::init(225), cl::ZeroOrMore, cl::desc("Control the amount of inlining to perform (default = 225)")); +static cl::opt<bool> +RespectHint("respect-inlinehint", cl::Hidden, + cl::desc("Respect the inlinehint attribute")); + +// Threshold to use when inlinehint is given. +const int HintThreshold = 300; + +// Threshold to use when optsize is specified (and there is no -inline-limit). +const int OptSizeThreshold = 75; + Inliner::Inliner(void *ID) : CallGraphSCCPass(ID), InlineThreshold(InlineLimit) {} @@ -172,13 +182,21 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG, return true; } -unsigned Inliner::getInlineThreshold(Function* Caller) const { +unsigned Inliner::getInlineThreshold(CallSite CS) const { + // Listen to inlinehint when -respect-inlinehint is given. + Function *Callee = CS.getCalledFunction(); + if (RespectHint && Callee && !Callee->isDeclaration() && + Callee->hasFnAttr(Attribute::InlineHint)) + return HintThreshold; + + // Listen to optsize when -inline-limit is not given. + Function *Caller = CS.getCaller(); if (Caller && !Caller->isDeclaration() && Caller->hasFnAttr(Attribute::OptimizeForSize) && InlineLimit.getNumOccurrences() == 0) - return 75; - else - return InlineThreshold; + return OptSizeThreshold; + + return InlineThreshold; } /// shouldInline - Return true if the inliner should attempt to inline @@ -200,7 +218,7 @@ bool Inliner::shouldInline(CallSite CS) { int Cost = IC.getValue(); Function *Caller = CS.getCaller(); - int CurrentThreshold = getInlineThreshold(Caller); + int CurrentThreshold = getInlineThreshold(CS); float FudgeFactor = getInlineFudgeFactor(CS); if (Cost >= (int)(CurrentThreshold * FudgeFactor)) { DEBUG(dbgs() << " NOT Inlining: cost=" << Cost @@ -236,8 +254,7 @@ bool Inliner::shouldInline(CallSite CS) { outerCallsFound = true; int Cost2 = IC2.getValue(); - Function *Caller2 = CS2.getCaller(); - int CurrentThreshold2 = getInlineThreshold(Caller2); + int CurrentThreshold2 = getInlineThreshold(CS2); float FudgeFactor2 = getInlineFudgeFactor(CS2); if (Cost2 >= (int)(CurrentThreshold2 * FudgeFactor2)) |

