summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-01-20 17:51:28 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-01-20 17:51:28 +0000
commitf8526cb711ec96cd2d5aff30da57f65ae8e5b7b8 (patch)
treea1685f66e8771db293312e810184dabcad6b99f8
parent32f6a8d923e70fc342a611a1446d3ea031d6afd2 (diff)
downloadllvm-f8526cb711ec96cd2d5aff30da57f65ae8e5b7b8.tar.gz
llvm-f8526cb711ec96cd2d5aff30da57f65ae8e5b7b8.tar.bz2
llvm-f8526cb711ec96cd2d5aff30da57f65ae8e5b7b8.tar.xz
Move per-function inline threshold calculation to a method.
No functional change except the forgotten test for InlineLimit.getNumOccurrences() == 0 in the CurrentThreshold2 calculation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94007 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Transforms/IPO/InlinerPass.h6
-rw-r--r--lib/Transforms/IPO/Inliner.cpp26
2 files changed, 18 insertions, 14 deletions
diff --git a/include/llvm/Transforms/IPO/InlinerPass.h b/include/llvm/Transforms/IPO/InlinerPass.h
index 5d00f4215a..dc5e644c7f 100644
--- a/include/llvm/Transforms/IPO/InlinerPass.h
+++ b/include/llvm/Transforms/IPO/InlinerPass.h
@@ -51,6 +51,12 @@ struct Inliner : public CallGraphSCCPass {
///
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
/// determine the cost of inlining the specified call site. If the cost
/// returned is greater than the current inline threshold, the call site is
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index 5725db1b74..0990278908 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -171,7 +171,16 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
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
/// at the given CallSite.
bool Inliner::shouldInline(CallSite CS) {
@@ -190,14 +199,8 @@ bool Inliner::shouldInline(CallSite CS) {
}
int Cost = IC.getValue();
- int CurrentThreshold = InlineThreshold;
Function *Caller = CS.getCaller();
- if (Caller && !Caller->isDeclaration() &&
- Caller->hasFnAttr(Attribute::OptimizeForSize) &&
- InlineLimit.getNumOccurrences() == 0 &&
- InlineThreshold != 50)
- CurrentThreshold = 50;
-
+ int CurrentThreshold = getInlineThreshold(Caller);
float FudgeFactor = getInlineFudgeFactor(CS);
if (Cost >= (int)(CurrentThreshold * FudgeFactor)) {
DEBUG(dbgs() << " NOT Inlining: cost=" << Cost
@@ -233,13 +236,8 @@ bool Inliner::shouldInline(CallSite CS) {
outerCallsFound = true;
int Cost2 = IC2.getValue();
- int CurrentThreshold2 = InlineThreshold;
Function *Caller2 = CS2.getCaller();
- if (Caller2 && !Caller2->isDeclaration() &&
- Caller2->hasFnAttr(Attribute::OptimizeForSize) &&
- InlineThreshold != 50)
- CurrentThreshold2 = 50;
-
+ int CurrentThreshold2 = getInlineThreshold(Caller2);
float FudgeFactor2 = getInlineFudgeFactor(CS2);
if (Cost2 >= (int)(CurrentThreshold2 * FudgeFactor2))