<div dir="ltr"><div>Hello LLVM.</div><div><br></div><div>I have come across a subtle and rare interaction between debug information, vector instructions, and the cost heuristic used by the SimpleInliner (i.e. the InlineCost analysis).</div>
<div><br></div><div>It appears that debug intrinsics are counted in the number of instructions taken into consideration by the heuristic. They are also later discounted as being "simplified", so they do not directly affect the inline Cost, but they are taken into account when evaluating the fraction of instructions that are vector instructions. This fraction is used to determine whether to apply a hidden "VectorBonus" to the inlining Threshold, and therefore there is a subtle interaction which means that debug intrinsics can affect the inlining decision.</div>
<div><br></div><div>The attached patch fixes the problem by making the inline cost heuristic skip debug intrinsics altogether when examining instructions.</div><div>I have also added a couple of debug prints to the already existing ones, which I think are generally useful to debug the inline cost heuristic.</div>
<div><br></div><div>I have included a test in which I have manufactured a situation where vector instructions would be most of the function's code but they are outnumbered by debug intrinsics when debug information is present. The test exposes the problem in the current trunk and passes with my fix.</div>
<div><br></div><div>Please submit for me if you accept this patch, as I do not have commit access.</div><div><br></div><div>Cheers,</div><div>    Dario Domizioli</div><div>    SN Systems - Sony Computer Entertainment</div>
<div><br></div></div>