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: Some optimization thoughts (and thanks!)


> The compiler can't know how often a function is called, only the linker
> can.  This would be possible for static functions, but I'd be highly
> surpriced when static functions with one caller aren't already inlined :/

They are only inlined if they precede the caller, and are below the
inlining threshold.  Most functions (those above the inlining threshold)
are immediately after optimization, before gcc tackels the next one,
so gcc doesn't know if a function is called just once when it has to
make the decision if to inline or not.

But even if it knew, it would not be desirable to indiscriminately inline
functions, not with the way the register allocator works right now.
For a large inlined function, the caller with inlined callee tends to
be larger and slower than the caller with out-of-line callee together.
This is because the register allocator is rather clumsy when faced with
a large overall demand of registers in a large function.
Two optimization techniques - live range splitting and shrink wrapping -
promise to overcome these problems, but they create variable /
register/memory assignments that are hard or impossible to describe with
some (most?) debugging information formats.


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