On Sat, Oct 6, 2012 at 7:01 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank" class="cremed">nicholas@mxc.ca</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Bob Wilson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: bwilson<br>
Date: Sat Oct  6 20:11:19 2012<br>
New Revision: 165367<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=165367&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-<u></u>project?rev=165367&view=rev</a><br>
Log:<br>
Make sure always-inline functions get inlined.<rdar://problem/<u></u>12423986><br>
<br>
Without this change, when the estimated cost for inlining a function with<br>
an "alwaysinline" attribute was lower than the inlining threshold, the<br>
getInlineCost function was returning that estimated cost rather than the<br>
special InlineCost::AlwaysInlineCost value. That is fine in the normal<br>
inlining case, but it can fail when the inliner considers the opportunity<br>
cost of inlining into an internal or linkonce-odr function. It may decide<br>
not to inline the always-inline function in that case. The fix here is just<br>
to make getInlineCost always return the special value for always-inline<br>
functions. I ran into this building clang with libc++. Tablegen failed to<br>
link because of an always-inline function that was not inlined. I have been<br>
unable to reduce the testcase down to a reasonable size.<br>
</blockquote>
<br></div>
I don't think this patch is correct. There's an -always-inline pass which shouldn't reach this code in InlineCost at all. Why didn't that kick in?<br></blockquote><div><br></div><div>IIRC, we don't run that pass outside of -O0. See my email to Bob, I think the better fix is to run that pass always, and remove all of th ealways-inline hackery from this pass. See the silly hacks both in PassManagerBuilder to allow clients to arbitrarily clobber the inliner pass used, and in lib/CodeGen/BackendUtil in Clang to set this up.</div>
<div><br></div><div>Some of this stems from even more silliness with -O2 -fno-inline where we still run the always inliner pass....</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Nick<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Modified:<br>
     llvm/trunk/lib/Analysis/<u></u>InlineCost.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/<u></u>InlineCost.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=165367&r1=165366&r2=165367&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/<u></u>Analysis/InlineCost.cpp?rev=<u></u>165367&r1=165366&r2=165367&<u></u>view=diff</a><br>

==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/Analysis/<u></u>InlineCost.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/<u></u>InlineCost.cpp Sat Oct  6 20:11:19 2012<br>
@@ -142,6 +142,7 @@<br>
<br>
    int getThreshold() { return Threshold; }<br>
    int getCost() { return Cost; }<br>
+  bool isAlwaysInline() { return AlwaysInline; }<br>
<br>
    // Keep a bunch of stats about the cost savings found so we can print them<br>
    // out when debugging.<br>
@@ -1057,7 +1058,8 @@<br>
    // Check if there was a reason to force inlining or no inlining.<br></div>
    if (!ShouldInline&&  CA.getCost()<  CA.getThreshold())<br>
      return InlineCost::getNever();<br>
-  if (ShouldInline&&  CA.getCost()>= CA.getThreshold())<br>
+  if (ShouldInline&&  (CA.isAlwaysInline() ||<div class="im"><br>
+                       CA.getCost()>= CA.getThreshold()))<br>
      return InlineCost::getAlways();<br>
<br>
    return llvm::InlineCost::get(CA.<u></u>getCost(), CA.getThreshold());<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
</div></blockquote><div class="HOEnZb"><div class="h5">
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>