<div dir="ltr"><div>Hm...<br><br>I had considered changing the calculation so that the 
VectorBonus fraction was based on the number of non-simplified 
instructions (i.e. NumInstructions - NumInstructionsSimplified), but
 then I decided to go for a less risky change because I wasn't sure what
 other kinds of instructions ended up in the "simplified" bucket. And furthermore some vector instructions may be simplified too, so the whole logic gets messy pretty quickly. The existence of a "hidden bonus" is itself quite odd (and 
the fact that it didn't appear in the debug prints made the 
investigation harder - hence my debug change too), so I'd understand if 
you wanted to wait and properly rework the inline heuristic.<br>



<br>
</div><div>This specific change should only impact compilations with 
debug information, and furthermore it would just realign their result to
 what the correspondent non-debug compilation does. Non-debug builds are
 already using the increased threshold and they inline all the functions
 that would be affected by this change in debug builds, so this doesn't 
technically increase our willingness to inline functions... it just 
makes sure that we are coherent with and without -g. I see your general point about possible regressions though.<br>
<br>


</div><div>I don't know... I think this could work as an incremental change towards properly fixing the VectorBonus issues, but that's just my opinion.<br></div><div><br></div><div>Cheers,<br></div><div>    Dario Domizioli<br>
</div>
    SN Systems - Sony Computer Entertainment<br><br><br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 31 January 2014 21:06, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> -----Original Message-----<br>
> From: <a href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-">llvm-commits-</a><br>
> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of Eric Christopher<br>
> Sent: Friday, January 31, 2014 12:10 PM<br>
> To: Chandler Carruth<br>
> Cc: Commit Messages and Patches for LLVM<br>
> Subject: Re: [PATCH] Fix for inlining decision affected by debug<br>
> intrinsics<br>
><br>
> I'd rather ignore all non-code generating heuristics myself -<br>
> including the lifetime heuristics. If they're not going to affect the<br>
> size of the generated code then they shouldn't be considered. Also,<br>
> debug shouldn't affect optimization decisions. :)<br>
<br>
</div>Right, that's what prompted this in the first place.  This is by<br>
far the most egregious case that we've found, so far the others<br>
have been minor, along the lines of PR18590.<br>
The ideal is that -g doesn't affect the final machine code at all,<br>
of course.<br>
--paulr<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> -eric<br>
><br>
> On Fri, Jan 31, 2014 at 12:06 PM, Chandler Carruth<br>
> <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<br>
> ><br>
> > On Fri, Jan 31, 2014 at 10:55 AM, Dario Domizioli<br>
> > <<a href="mailto:dario.domizioli@gmail.com">dario.domizioli@gmail.com</a>> wrote:<br>
> >><br>
> >> I have come across a subtle and rare interaction between debug<br>
> >> information, vector instructions, and the cost heuristic used by the<br>
> >> SimpleInliner (i.e. the InlineCost analysis).<br>
> >><br>
> >> It appears that debug intrinsics are counted in the number of<br>
> instructions<br>
> >> taken into consideration by the heuristic. They are also later<br>
> discounted as<br>
> >> being "simplified", so they do not directly affect the inline Cost,<br>
> but they<br>
> >> are taken into account when evaluating the fraction of instructions<br>
> that are<br>
> >> vector instructions. This fraction is used to determine whether to<br>
> apply a<br>
> >> hidden "VectorBonus" to the inlining Threshold, and therefore there<br>
> is a<br>
> >> subtle interaction which means that debug intrinsics can affect the<br>
> inlining<br>
> >> decision.<br>
> >><br>
> >> The attached patch fixes the problem by making the inline cost<br>
> heuristic<br>
> >> skip debug intrinsics altogether when examining instructions.<br>
> >> I have also added a couple of debug prints to the already existing<br>
> ones,<br>
> >> which I think are generally useful to debug the inline cost<br>
> heuristic.<br>
> ><br>
> ><br>
> > I don't think this bug has anything to do with debug info intrinsics,<br>
> and so<br>
> > I don't think this is the correct patch.<br>
> ><br>
> > I think the bug is that instructions which we simplify away are<br>
> counted<br>
> > toward the vector bonus. There should be no difference between debug<br>
> info<br>
> > intrinsics and lifetime intrinsics. So the fix should be general and<br>
> apply<br>
> > to the the basic cost.<br>
> ><br>
> ><br>
> > However, as a meta point, the "vector bonus" is the single worst<br>
> aspect of<br>
> > our inline heuristics. To an extent, I would rather *remove* the<br>
> vector<br>
> > bonus than make it more correct... but perhaps that battle is best<br>
> fought<br>
> > another day.<br>
> ><br>
> > _______________________________________________<br>
> > llvm-commits mailing list<br>
> > <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
> ><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>