[llvm] r278312 - Make more fields of InlineParams Optional.
Easwaran Raman via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 20:58:06 PDT 2016
Author: eraman
Date: Wed Aug 10 22:58:05 2016
New Revision: 278312
URL: http://llvm.org/viewvc/llvm-project?rev=278312&view=rev
Log:
Make more fields of InlineParams Optional.
Differential revision: https://reviews.llvm.org/D23386
Modified:
llvm/trunk/include/llvm/Analysis/InlineCost.h
llvm/trunk/lib/Analysis/InlineCost.cpp
Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?rev=278312&r1=278311&r2=278312&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/InlineCost.h (original)
+++ llvm/trunk/include/llvm/Analysis/InlineCost.h Wed Aug 10 22:58:05 2016
@@ -124,7 +124,7 @@ struct InlineParams {
int DefaultThreshold;
/// Threshold to use for callees with inline hint.
- int HintThreshold;
+ Optional<int> HintThreshold;
/// Threshold to use for cold callees.
Optional<int> ColdThreshold;
@@ -136,7 +136,7 @@ struct InlineParams {
Optional<int> OptMinSizeThreshold;
/// Threshold to use when the callsite is considered hot.
- int HotCallSiteThreshold;
+ Optional<int> HotCallSiteThreshold;
};
/// Generate the parameters to tune the inline cost analysis based only on the
Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=278312&r1=278311&r2=278312&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Wed Aug 10 22:58:05 2016
@@ -624,6 +624,11 @@ void CallAnalyzer::updateThreshold(CallS
return B ? std::min(A, B.getValue()) : A;
};
+ // return max(A, B) if B is valid.
+ auto MaxIfValid = [](int A, Optional<int> B) {
+ return B ? std::max(A, B.getValue()) : A;
+ };
+
// Use the OptMinSizeThreshold or OptSizeThreshold knob if they are available
// and reduce the threshold if the caller has the necessary attribute.
if (Caller->optForMinSize())
@@ -644,11 +649,10 @@ void CallAnalyzer::updateThreshold(CallS
bool InlineHint = Callee.hasFnAttribute(Attribute::InlineHint) ||
PSI->isHotFunction(&Callee);
if (InlineHint && !Caller->optForMinSize())
- Threshold = std::max(Threshold, Params.HintThreshold);
+ Threshold = MaxIfValid(Threshold, Params.HintThreshold);
- if (HotCallsite && HotCallSiteThreshold > Threshold &&
- !Caller->optForMinSize())
- Threshold = std::max(Threshold, Params.HotCallSiteThreshold);
+ if (HotCallsite && !Caller->optForMinSize())
+ Threshold = MaxIfValid(Threshold, Params.HotCallSiteThreshold);
bool ColdCallee = PSI->isColdFunction(&Callee);
// For cold callees, use the ColdThreshold knob if it is available and reduces
More information about the llvm-commits
mailing list