This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Inlining heuristics for C++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]