[PATCH] D34471: [Inliner] Boost inlining of an indirect call to always_inline function.

Easwaran Raman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 13:42:55 PDT 2017


eraman added a comment.

In https://reviews.llvm.org/D34471#788221, @efriedma wrote:

> This seems likely to lead to surprising behavior.  LastCallToStaticBonus is very large, so we'll end up duplicating a lot of code in some cases, which could be surprising.  On the other hand, it isn't infinitely large, so you can't depend on always_inline to trigger the behavior reliably.
>
> What's the motivation for this change?


Consider a function B that takes a function pointer as an argument and calls that.  Let's assume A invokes B and passes a pointer to C which has always_inline attribute. It is reasonable to relax the A->B inlining limits so that we could honor the always_inline hint on C. I think this is a fairly uncommon scenario that size increase is not a concern in general, but yes this could end up duplicating a lot in some cases. One way to think about is what could the programmer do to ensure C always gets inlined. They could clone B to B' that directly calls C and  change a subset of B's callers to B'. This roughly doubles the size of B. We could perhaps approximate this by giving a bonus of <some large value> / (# callers of B in the module).


https://reviews.llvm.org/D34471





More information about the llvm-commits mailing list