<div dir="ltr">If Cost=0 is supposed to mean inlining has zero cost, we should make sure Cost > 0 when the loop in InlineCost.cpp (line 1306) bails out early.<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 4:26 PM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">If Cost = 0 doesn't mean inlining the function has zero cost, that seems broken.<br>
<br>
I think eraman knows this code. Maybe he wants to take a look?<br>
<div class=""><div class="h5"><br>
On Mon, Feb 22, 2016 at 9:11 PM, Akira Hatanaka via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Hi Hans,<br>
><br>
> This commit (or r252595) causes the inliner to inline functions you don't<br>
> want to inline (large functions) in some cases. For example, if you compile<br>
> the attached test case with "opt -inline", function "callee" will always get<br>
> inlined even after replicating the inline-asm instruction in the last basic<br>
> block a large number of times. This happens because the loop in<br>
> CallAnalyzer::analyzeCall that visits the basic blocks of "callee" breaks<br>
> out when Cost exceeds Threshold, and when that happens Cost happens to be 0.<br>
> In this case Cost doesn't represent the true cost of the function (Cost<=0<br>
> doesn't mean "inlining is free").<br>
><br>
> Could you take a look?<br>
><br>
> On Fri, Feb 5, 2016 at 12:32 PM, Hans Wennborg via llvm-commits<br>
> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: hans<br>
>> Date: Fri Feb  5 14:32:42 2016<br>
>> New Revision: 259915<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=259915&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=259915&view=rev</a><br>
>> Log:<br>
>> CallAnalyzer::analyzeCall: change the condition back to "Cost < Threshold"<br>
>><br>
>> In r252595, I inadvertently changed the condition to "Cost <= Threshold",<br>
>> which caused a significant size regression in Chrome. This commit<br>
>> rectifies<br>
>> that.<br>
>><br>
>> Modified:<br>
>>     llvm/trunk/lib/Analysis/InlineCost.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=259915&r1=259914&r2=259915&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=259915&r1=259914&r2=259915&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)<br>
>> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Fri Feb  5 14:32:42 2016<br>
>> @@ -1392,7 +1392,7 @@ bool CallAnalyzer::analyzeCall(CallSite<br>
>>    else if (NumVectorInstructions <= NumInstructions / 2)<br>
>>      Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus);<br>
>><br>
>> -  return Cost <= std::max(0, Threshold);<br>
>> +  return Cost < std::max(1, Threshold);<br>
>>  }<br>
>><br>
>>  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div></blockquote></div><br></div></div>