This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inlining heuristics for C++
- To: Daniel Berlin <dan at cgsoftware dot com>
- Subject: Re: Inlining heuristics for C++
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Tue, 10 Jul 2001 12:22:44 +1000
- Cc: gcc at gcc dot gnu dot org
- References: <87r8vpo8rw.fsf@cgsoftware.com>
On 09-Jul-2001, Daniel Berlin <dan@cgsoftware.com> wrote:
> I've got a very simple heuristic that says "don't inline things <some
> configurable number currently defaulting to 10> times bigger than we
> were when we started inlining, into us" I.E. don't inline a 100
> statement function into a 10 statement one.
>
> This is effectively expressing the rule: "Small functions should be
> inlined into larger ones. Larger functions should not be inlined into
> small ones".
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.
For this to work, you need to do parse and analyze the whole translation
unit before emitting code, to get information about call counts, and
to enable elimination of dead functions.
(Is compiling whole translation units at a time, rather than compiling
each function in turn, what you meant by "region-based compilation"?
I found that term confusing -- at first I thought you were talking
about region-based memory management, as in the SML kit with Regions,
which is a very different thing.)
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.