mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-14 21:51:19 +00:00
Move per-function inline threshold calculation to a method.
No functional change except the forgotten test for InlineLimit.getNumOccurrences() == 0 in the CurrentThreshold2 calculation. llvm-svn: 94007
This commit is contained in:
parent
ffc364d7e2
commit
ac14f3bf31
@ -51,6 +51,12 @@ struct Inliner : public CallGraphSCCPass {
|
|||||||
///
|
///
|
||||||
unsigned getInlineThreshold() const { return InlineThreshold; }
|
unsigned getInlineThreshold() const { return InlineThreshold; }
|
||||||
|
|
||||||
|
/// Calculate the inline threshold for given Caller. This threshold is lower
|
||||||
|
/// if Caller is marked with OptimizeForSize and -inline-threshold is not
|
||||||
|
/// given on the comand line.
|
||||||
|
///
|
||||||
|
unsigned getInlineThreshold(Function* Caller) const;
|
||||||
|
|
||||||
/// getInlineCost - This method must be implemented by the subclass to
|
/// getInlineCost - This method must be implemented by the subclass to
|
||||||
/// determine the cost of inlining the specified call site. If the cost
|
/// determine the cost of inlining the specified call site. If the cost
|
||||||
/// returned is greater than the current inline threshold, the call site is
|
/// returned is greater than the current inline threshold, the call site is
|
||||||
|
@ -172,6 +172,15 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Inliner::getInlineThreshold(Function* Caller) const {
|
||||||
|
if (Caller && !Caller->isDeclaration() &&
|
||||||
|
Caller->hasFnAttr(Attribute::OptimizeForSize) &&
|
||||||
|
InlineLimit.getNumOccurrences() == 0)
|
||||||
|
return 50;
|
||||||
|
else
|
||||||
|
return InlineThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
/// shouldInline - Return true if the inliner should attempt to inline
|
/// shouldInline - Return true if the inliner should attempt to inline
|
||||||
/// at the given CallSite.
|
/// at the given CallSite.
|
||||||
bool Inliner::shouldInline(CallSite CS) {
|
bool Inliner::shouldInline(CallSite CS) {
|
||||||
@ -190,14 +199,8 @@ bool Inliner::shouldInline(CallSite CS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Cost = IC.getValue();
|
int Cost = IC.getValue();
|
||||||
int CurrentThreshold = InlineThreshold;
|
|
||||||
Function *Caller = CS.getCaller();
|
Function *Caller = CS.getCaller();
|
||||||
if (Caller && !Caller->isDeclaration() &&
|
int CurrentThreshold = getInlineThreshold(Caller);
|
||||||
Caller->hasFnAttr(Attribute::OptimizeForSize) &&
|
|
||||||
InlineLimit.getNumOccurrences() == 0 &&
|
|
||||||
InlineThreshold != 50)
|
|
||||||
CurrentThreshold = 50;
|
|
||||||
|
|
||||||
float FudgeFactor = getInlineFudgeFactor(CS);
|
float FudgeFactor = getInlineFudgeFactor(CS);
|
||||||
if (Cost >= (int)(CurrentThreshold * FudgeFactor)) {
|
if (Cost >= (int)(CurrentThreshold * FudgeFactor)) {
|
||||||
DEBUG(dbgs() << " NOT Inlining: cost=" << Cost
|
DEBUG(dbgs() << " NOT Inlining: cost=" << Cost
|
||||||
@ -233,13 +236,8 @@ bool Inliner::shouldInline(CallSite CS) {
|
|||||||
|
|
||||||
outerCallsFound = true;
|
outerCallsFound = true;
|
||||||
int Cost2 = IC2.getValue();
|
int Cost2 = IC2.getValue();
|
||||||
int CurrentThreshold2 = InlineThreshold;
|
|
||||||
Function *Caller2 = CS2.getCaller();
|
Function *Caller2 = CS2.getCaller();
|
||||||
if (Caller2 && !Caller2->isDeclaration() &&
|
int CurrentThreshold2 = getInlineThreshold(Caller2);
|
||||||
Caller2->hasFnAttr(Attribute::OptimizeForSize) &&
|
|
||||||
InlineThreshold != 50)
|
|
||||||
CurrentThreshold2 = 50;
|
|
||||||
|
|
||||||
float FudgeFactor2 = getInlineFudgeFactor(CS2);
|
float FudgeFactor2 = getInlineFudgeFactor(CS2);
|
||||||
|
|
||||||
if (Cost2 >= (int)(CurrentThreshold2 * FudgeFactor2))
|
if (Cost2 >= (int)(CurrentThreshold2 * FudgeFactor2))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user