[PATCH] D34017: Do not early-inline recursive calls in sample profile loader.

Kyle Butt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 7 16:53:47 PDT 2017


iteratee added a comment.

In https://reviews.llvm.org/D34017#775713, @danielcdh wrote:

> In https://reviews.llvm.org/D34017#775712, @iteratee wrote:
>
> > 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
>
>
> 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.


I meant to do it only if the inline is recursive. The overhead should be much lower in that case. 
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.


https://reviews.llvm.org/D34017





More information about the llvm-commits mailing list