[llvm] r277860 - Replace hot-callsite based heuristic to use its own threshold parameter instead of share inline-hint parameter

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 5 13:57:38 PDT 2016


This seems to be causing a new warning:

...llvm/lib/Analysis/InlineCost.cpp:648:5: warning: add explicit braces to
avoid dangling else [-Wdangling-else]
    else if (PSI->isColdCount(TotalWeight))
    ^


On Fri, Aug 5, 2016 at 1:28 PM, Dehao Chen via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: dehao
> Date: Fri Aug  5 15:28:41 2016
> New Revision: 277860
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277860&view=rev
> Log:
> Replace hot-callsite based heuristic to use its own threshold parameter
> instead of share inline-hint parameter
>
> Summary: Hot callsites should have higher threshold than inline hints.
> This patch uses separate threshold parameter for hot callsites.
>
> Reviewers: davidxl, eraman
>
> Subscribers: Prazek, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D22368
>
> Modified:
>     llvm/trunk/lib/Analysis/InlineCost.cpp
>     llvm/trunk/test/Transforms/Inline/inline-hot-callsite.ll
>
> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Analysis/InlineCost.cpp?rev=277860&r1=277859&r2=277860&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Fri Aug  5 15:28:41 2016
> @@ -66,6 +66,11 @@ static cl::opt<int> ColdThreshold(
>      "inlinecold-threshold", cl::Hidden, cl::init(225),
>      cl::desc("Threshold for inlining functions with cold attribute"));
>
> +static cl::opt<int>
> +    HotCallSiteThreshold("hot-callsite-threshold", cl::Hidden,
> cl::init(3000),
> +                         cl::ZeroOrMore,
> +                         cl::desc("Threshold for hot callsites "));
> +
>  namespace {
>
>  class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
> @@ -635,27 +640,33 @@ void CallAnalyzer::updateThreshold(CallS
>    }
>
>    bool HotCallsite = false;
> +  bool ColdCallsite = false;
>    uint64_t TotalWeight;
> -  if (CS.getInstruction()->extractProfTotalWeight(TotalWeight) &&
> -      PSI->isHotCount(TotalWeight))
> -    HotCallsite = true;
> +  if (CS.getInstruction()->extractProfTotalWeight(TotalWeight))
> +    if (PSI->isHotCount(TotalWeight))
> +      HotCallsite = true;
> +    else if (PSI->isColdCount(TotalWeight))
> +      ColdCallsite = true;
>
>    // Listen to the inlinehint attribute or profile based hotness
> information
>    // when it would increase the threshold and the caller does not need to
>    // minimize its size.
>    bool InlineHint = Callee.hasFnAttribute(Attribute::InlineHint) ||
> -                    PSI->isHotFunction(&Callee) ||
> -                    HotCallsite;
> +                    PSI->isHotFunction(&Callee);
>    if (InlineHint && HintThreshold > Threshold && !Caller->optForMinSize())
>      Threshold = HintThreshold;
>
> +  if (HotCallsite && HotCallSiteThreshold > Threshold &&
> +      !Caller->optForMinSize())
> +    Threshold = HotCallSiteThreshold;
> +
>    bool ColdCallee = PSI->isColdFunction(&Callee);
>    // Command line argument for DefaultInlineThreshold will override the
> default
>    // ColdThreshold. If we have -inline-threshold but no
> -inlinecold-threshold,
>    // do not use the default cold threshold even if it is smaller.
>    if ((DefaultInlineThreshold.getNumOccurrences() == 0 ||
>         ColdThreshold.getNumOccurrences() > 0) &&
> -      ColdCallee && ColdThreshold < Threshold)
> +      (ColdCallee || ColdCallsite) && ColdThreshold < Threshold)
>      Threshold = ColdThreshold;
>
>    // Finally, take the target-specific inlining threshold multiplier into
>
> Modified: llvm/trunk/test/Transforms/Inline/inline-hot-callsite.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> Transforms/Inline/inline-hot-callsite.ll?rev=277860&r1=
> 277859&r2=277860&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/Transforms/Inline/inline-hot-callsite.ll (original)
> +++ llvm/trunk/test/Transforms/Inline/inline-hot-callsite.ll Fri Aug  5
> 15:28:41 2016
> @@ -1,4 +1,4 @@
> -; RUN: opt < %s -inline -inline-threshold=0 -inlinehint-threshold=100 -S
> | FileCheck %s
> +; RUN: opt < %s -inline -inline-threshold=0 -hot-callsite-threshold=100
> -S | FileCheck %s
>
>  ; This tests that a hot callsite gets the (higher) inlinehint-threshold
> even without
>  ; without inline hints and gets inlined because the cost is less than
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160805/a7b32f9c/attachment.html>


More information about the llvm-commits mailing list