[llvm] r259915 - CallAnalyzer::analyzeCall: change the condition back to "Cost < Threshold"

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 21:11:08 PST 2016


Hi Hans,

This commit (or r252595) causes the inliner to inline functions you don't
want to inline (large functions) in some cases. For example, if you compile
the attached test case with "opt -inline", function "callee" will always
get inlined even after replicating the inline-asm instruction in the last
basic block a large number of times. This happens because the loop in
CallAnalyzer::analyzeCall that visits the basic blocks of "callee" breaks
out when Cost exceeds Threshold, and when that happens Cost happens to be
0. In this case Cost doesn't represent the true cost of the function
(Cost<=0 doesn't mean "inlining is free").

Could you take a look?

On Fri, Feb 5, 2016 at 12:32 PM, Hans Wennborg via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: hans
> Date: Fri Feb  5 14:32:42 2016
> New Revision: 259915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259915&view=rev
> Log:
> CallAnalyzer::analyzeCall: change the condition back to "Cost < Threshold"
>
> In r252595, I inadvertently changed the condition to "Cost <= Threshold",
> which caused a significant size regression in Chrome. This commit rectifies
> that.
>
> Modified:
>     llvm/trunk/lib/Analysis/InlineCost.cpp
>
> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=259915&r1=259914&r2=259915&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Fri Feb  5 14:32:42 2016
> @@ -1392,7 +1392,7 @@ bool CallAnalyzer::analyzeCall(CallSite
>    else if (NumVectorInstructions <= NumInstructions / 2)
>      Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus);
>
> -  return Cost <= std::max(0, Threshold);
> +  return Cost < std::max(1, Threshold);
>  }
>
>  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
>
>
> _______________________________________________
> 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/20160222/6d32e149/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.ll
Type: application/octet-stream
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160222/6d32e149/attachment.obj>


More information about the llvm-commits mailing list