diff options
author | Easwaran Raman <eraman@google.com> | 2016-08-11 03:58:05 +0000 |
---|---|---|
committer | Easwaran Raman <eraman@google.com> | 2016-08-11 03:58:05 +0000 |
commit | 0d58fcac994227b465a30d03c4bf6651ceedbab1 (patch) | |
tree | 5295faf874bc9acca50e97db60d9bc84f6500c39 /llvm/lib/Analysis/InlineCost.cpp | |
parent | 18dd773016bba0520447b2d325629b09b819eebf (diff) | |
download | bcm5719-llvm-0d58fcac994227b465a30d03c4bf6651ceedbab1.tar.gz bcm5719-llvm-0d58fcac994227b465a30d03c4bf6651ceedbab1.zip |
Make more fields of InlineParams Optional.
Differential revision: https://reviews.llvm.org/D23386
llvm-svn: 278312
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index c0ac6c86ce9..9fbb2853594 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -624,6 +624,11 @@ void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) { 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(CallSite CS, Function &Callee) { 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 |