aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/InlineSimple.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2016-01-14 23:16:29 +0000
committerEaswaran Raman <eraman@google.com>2016-01-14 23:16:29 +0000
commitf4bb2f0dc322e15dddda95eafbb2eb0485f03e69 (patch)
treea28e6ac212c09266ad6b4d7d25c99b00f3f6b1d3 /llvm/lib/Transforms/IPO/InlineSimple.cpp
parent14714c4181d8cb142ed684c9abfba835b9167410 (diff)
downloadllvm-f4bb2f0dc322e15dddda95eafbb2eb0485f03e69.zip
llvm-f4bb2f0dc322e15dddda95eafbb2eb0485f03e69.tar.gz
llvm-f4bb2f0dc322e15dddda95eafbb2eb0485f03e69.tar.bz2
Refactor threshold computation for inline cost analysis
Differential Revision: http://reviews.llvm.org/D15401 llvm-svn: 257832
Diffstat (limited to 'llvm/lib/Transforms/IPO/InlineSimple.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/InlineSimple.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 45609f8..a87c0d3 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -38,14 +38,19 @@ namespace {
/// inliner pass and the always inliner pass. The two passes use different cost
/// analyses to determine when to inline.
class SimpleInliner : public Inliner {
+ // This field is populated based on one of the following:
+ // optimization or size optimization levels,
+ // --inline-threshold flag,
+ // user specified value.
+ int DefaultThreshold;
public:
- SimpleInliner() : Inliner(ID) {
+ SimpleInliner()
+ : Inliner(ID), DefaultThreshold(llvm::getDefaultInlineThreshold()) {
initializeSimpleInlinerPass(*PassRegistry::getPassRegistry());
}
- SimpleInliner(int Threshold)
- : Inliner(ID, Threshold, /*InsertLifetime*/ true) {
+ SimpleInliner(int Threshold) : Inliner(ID), DefaultThreshold(Threshold) {
initializeSimpleInlinerPass(*PassRegistry::getPassRegistry());
}
@@ -54,7 +59,7 @@ public:
InlineCost getInlineCost(CallSite CS) override {
Function *Callee = CS.getCalledFunction();
TargetTransformInfo &TTI = TTIWP->getTTI(*Callee);
- return llvm::getInlineCost(CS, getInlineThreshold(CS), TTI, ACT);
+ return llvm::getInlineCost(CS, DefaultThreshold, TTI, ACT);
}
bool runOnSCC(CallGraphSCC &SCC) override;
@@ -64,17 +69,6 @@ private:
TargetTransformInfoWrapperPass *TTIWP;
};
-static int computeThresholdFromOptLevels(unsigned OptLevel,
- unsigned SizeOptLevel) {
- if (OptLevel > 2)
- return 275;
- if (SizeOptLevel == 1) // -Os
- return 75;
- if (SizeOptLevel == 2) // -Oz
- return 25;
- return 225;
-}
-
} // end anonymous namespace
char SimpleInliner::ID = 0;
@@ -96,7 +90,7 @@ Pass *llvm::createFunctionInliningPass(int Threshold) {
Pass *llvm::createFunctionInliningPass(unsigned OptLevel,
unsigned SizeOptLevel) {
return new SimpleInliner(
- computeThresholdFromOptLevels(OptLevel, SizeOptLevel));
+ llvm::computeThresholdFromOptLevels(OptLevel, SizeOptLevel));
}
bool SimpleInliner::runOnSCC(CallGraphSCC &SCC) {