aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO/Inliner.cpp
diff options
context:
space:
mode:
authorPatrik Hägglund <patrik.h.hagglund@ericsson.com>2012-05-23 13:42:57 +0000
committerPatrik Hägglund <patrik.h.hagglund@ericsson.com>2012-05-23 13:42:57 +0000
commitab767213fdfc219384e26b8073783cb883974dcd (patch)
tree78c7545b2e79c553055dea6021f12d18471881f2 /lib/Transforms/IPO/Inliner.cpp
parent9ce6f6fe5e44a5bd4c4dcee660cddd197aec5307 (diff)
downloadexternal_llvm-ab767213fdfc219384e26b8073783cb883974dcd.zip
external_llvm-ab767213fdfc219384e26b8073783cb883974dcd.tar.gz
external_llvm-ab767213fdfc219384e26b8073783cb883974dcd.tar.bz2
Fix the inliner so that the optsize function attribute don't alter the
inline threshold if the global inline threshold is lower (as for -Oz). Reviewed by Chandler Carruth and Bill Wendling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/Inliner.cpp')
-rw-r--r--lib/Transforms/IPO/Inliner.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index dc9cbfb..29a8218 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -201,19 +201,22 @@ static bool InlineCallIfPossible(CallSite CS, InlineFunctionInfo &IFI,
}
unsigned Inliner::getInlineThreshold(CallSite CS) const {
- int thres = InlineThreshold;
+ int thres = InlineThreshold; // -inline-threshold or else selected by
+ // overall opt level
- // Listen to optsize when -inline-limit is not given.
+ // If -inline-threshold is not given, listen to the optsize attribute when it
+ // would decrease the threshold.
Function *Caller = CS.getCaller();
- if (Caller && !Caller->isDeclaration() &&
- Caller->hasFnAttr(Attribute::OptimizeForSize) &&
- InlineLimit.getNumOccurrences() == 0)
+ bool OptSize = Caller && !Caller->isDeclaration() &&
+ Caller->hasFnAttr(Attribute::OptimizeForSize);
+ if (!(InlineLimit.getNumOccurrences() > 0) && OptSize && OptSizeThreshold < thres)
thres = OptSizeThreshold;
- // Listen to inlinehint when it would increase the threshold.
+ // Listen to the inlinehint attribute when it would increase the threshold.
Function *Callee = CS.getCalledFunction();
- if (HintThreshold > thres && Callee && !Callee->isDeclaration() &&
- Callee->hasFnAttr(Attribute::InlineHint))
+ bool InlineHint = Callee && !Callee->isDeclaration() &&
+ Callee->hasFnAttr(Attribute::InlineHint);
+ if (InlineHint && HintThreshold > thres)
thres = HintThreshold;
return thres;