From: Easwaran Raman Date: Thu, 11 Aug 2016 03:58:05 +0000 (+0000) Subject: Make more fields of InlineParams Optional. X-Git-Tag: llvmorg-4.0.0-rc1~12783 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d58fcac994227b465a30d03c4bf6651ceedbab1;p=platform%2Fupstream%2Fllvm.git Make more fields of InlineParams Optional. Differential revision: https://reviews.llvm.org/D23386 llvm-svn: 278312 --- diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h index 6b7adcc..50e4448 100644 --- a/llvm/include/llvm/Analysis/InlineCost.h +++ b/llvm/include/llvm/Analysis/InlineCost.h @@ -124,7 +124,7 @@ struct InlineParams { int DefaultThreshold; /// Threshold to use for callees with inline hint. - int HintThreshold; + Optional HintThreshold; /// Threshold to use for cold callees. Optional ColdThreshold; @@ -136,7 +136,7 @@ struct InlineParams { Optional OptMinSizeThreshold; /// Threshold to use when the callsite is considered hot. - int HotCallSiteThreshold; + Optional HotCallSiteThreshold; }; /// Generate the parameters to tune the inline cost analysis based only on the diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index c0ac6c8..9fbb285 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 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