<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 7, 2017 at 4:53 PM, Kyle Butt via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">iteratee added a comment.<br>
<span class=""><br>
In <a href="https://reviews.llvm.org/D34017#775713" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34017#775713</a>, @danielcdh wrote:<br>
<br>
> In <a href="https://reviews.llvm.org/D34017#775712" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34017#775712</a>, @iteratee wrote:<br>
><br>
> > It doesn't have to blow it up exponentially. Can we clone the function to be inlined, re-writing the recursive calls to call the clone, and then inline that? Similar to a worker-wrapper transformation<br>
><br>
><br>
> You mean clone the caller before any inlining, and inline that copy instead of the caller itself in early inlining? Yes we could do that, but that adds unnecessary copy overhead for every caller (which could be large). As llvm does not do recursive inlining anyway, this only solves cases where profile is collected from gcc binary, which should be temporary. So I guess it's not worth the effort to special-handle recursive early inlining.<br>
<br>
<br>
</span>I meant to do it only if the inline is recursive. The overhead should be much lower in that case.<br>
Clone the function, make the recursive calls call the clone, inline the clone. Repeat until you no longer want to inline any more, then take the remaining calls to the clone, and change them back. GC the clone. You could think of it as a kind of loop unrolling.<br></blockquote><div><br></div><div>Note that early inlining for Sample PGO is mainly driven by the need of profile matching. This patch  is not the right place to implement that.  What you described can be implemented in the main inliner pass which also needs to deal with related inline cost (e.g, recursive inlining level etc) -- recursive inlining is one of main missing features in LLVM inliner.</div><div><br></div><div>David</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<a href="https://reviews.llvm.org/D34017" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34017</a><br>
<br>
<br>
<br>
</blockquote></div><br></div></div>