This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inlining heuristics for C++
- To: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Subject: Re: Inlining heuristics for C++
- From: Andi Kleen <ak at suse dot de>
- Date: 10 Jul 2001 11:36:38 +0200
- Cc: dan at cgsoftware dot com, gcc at gcc dot gnu dot org
- References: <87r8vpo8rw.fsf@cgsoftware.com.suse.lists.egcs> <20010710122244.A14584@hg.cs.mu.oz.au.suse.lists.egcs>
Fergus Henderson <fjh@cs.mu.oz.au> writes:
>
> There is an exception to this. Functions which are only called once,
> and which are defined in this translation unit and not exported, should
> almost always be inlined (after which the original copy of the function
> is dead code and can be eliminated), even if they are much larger than
> the function into which they are being inlined.
This has some bad interactions with gcc's current register allocator though.
It cannot split register variable livetimes currently. When bigger functions
are inlined then the variables in the outer function (with their scope
extending over the function call) have a much smaller chance to get a
register because they're usually already used up by the inlined bigger
function. With a function call gcc can save/restore them around the
function; with inline it tends to use stack variables for the "outside"
variables which often hurts.
Of course it would be best to fix the register allocator to still do a
bettre job. Short term I suspect e.g. on register poor machines
like the x86 which also has fast CALL it's probably best to avoid bigger
inlines at least when there are many variables alive in the caller or
the call happens in a loop.
-Andi