aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2016-01-28 23:44:41 +0000
committerEaswaran Raman <eraman@google.com>2016-01-28 23:44:41 +0000
commit30a93c1848777202c1bbf8ef756b9c5c1a86e19e (patch)
treebbda0f4718093987c399d1bc21b37e250f914c80 /llvm/lib/Analysis/InlineCost.cpp
parent494ee5b049f0eabddc2055f337dc4b3b006a6041 (diff)
downloadllvm-30a93c1848777202c1bbf8ef756b9c5c1a86e19e.zip
llvm-30a93c1848777202c1bbf8ef756b9c5c1a86e19e.tar.gz
llvm-30a93c1848777202c1bbf8ef756b9c5c1a86e19e.tar.bz2
Lower inlining threshold when the caller has minsize attribute.
When the caller has optsize attribute, we reduce the inlinining threshold to OptSizeThreshold (=75) if it is not already lower than that. We don't do the same for minsize and I suspect it was not intentional. This also addresses a FIXME regarding checking optsize attribute explicitly instead of using the right wrapper. Differential Revision: http://reviews.llvm.org/D16493 llvm-svn: 259120
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 32e8e27..9196755 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -573,16 +573,16 @@ bool CallAnalyzer::isKnownNonNullInCallee(Value *V) {
}
void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) {
- // If -inline-threshold is not given, listen to the optsize attribute when it
- // would decrease the threshold.
+ // If -inline-threshold is not given, listen to the optsize and minsize
+ // attributes when they would decrease the threshold.
Function *Caller = CS.getCaller();
- // FIXME: Use Function::optForSize()
- bool OptSize = Caller->hasFnAttribute(Attribute::OptimizeForSize);
-
- if (!(DefaultInlineThreshold.getNumOccurrences() > 0) && OptSize &&
- OptSizeThreshold < Threshold)
- Threshold = OptSizeThreshold;
+ if (!(DefaultInlineThreshold.getNumOccurrences() > 0)) {
+ if (Caller->optForMinSize() && OptMinSizeThreshold < Threshold)
+ Threshold = OptMinSizeThreshold;
+ else if (Caller->optForSize() && OptSizeThreshold < Threshold)
+ Threshold = OptSizeThreshold;
+ }
// If profile information is available, use that to adjust threshold of hot
// and cold functions.