[LLVMdev] inlining with O3 and O4

Daniel Berlin
Wed, 29 Aug 2012 05:39:00 -0000

On Wed, Aug 29, 2012 at 12:11 AM, Ramanarayanan, Ramshankar
<Ramshankar.Ramanarayanan at amd.com> wrote:
> I am wondering how O4 vs O3 do inlining. With O4 it looks like inlining is
> done first on each file and then at linking phase. Wouldn’t it be a better
> alternative to delay inlining decisions until the link stage?
Yes and no.
Yes in the sense that you may make some better decisions.
No in the sense that you will end up with larger modules (assuming
some simple early CSE/etc is also done), and as a result of having
done no inlining, may make worse decisions at the link stage inlining,
depending on what IPA analysis you base your link stage inlining on
and when it runs.

It's certainly possible to have a link-phase only early inliner, and a
link-phase only later inliner, and you will, in general, get better
decisions than a local inliner + link phase inliner, but the cost you
pay is more memory usage, more disk usage, etc.