This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Os & inlining functions used only once
- To: aduret at enst dot fr (Alexandre Duret-Lutz)
- Subject: Re: -Os & inlining functions used only once
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Tue, 17 Apr 2001 10:04:11 -0700 (PDT)
- Cc: gcc at gcc dot gnu dot org
> I'm looking for a way to instruct GCC to inline all static
> functions which are used only once. The point is just to save
> the extra bytes required to make the calls and returns.
The compiler can't possibly tell that a static function is used only once
until it gets to the end of a compilation unit, and compilation units can
be arbitrarily large. The compiler does not pre-scan the whole file and
then go back and compile, so it can't do what you are asking for. It only
deals with one function at a time, and doesn't make assumptions about what
future functions will do.
> -finline-functions seems a good candidate but it doesn't appear
> to works with -Os:
If -Os is active and you also request inlining, the only functions that
get inlined are those that are so small that the inlined code is about the
same size as the code to pass the arguments and call the function (meaning
that we save space no matter how many copies we inline).
> Any hint why it doesn't work? Before looking at the code I
> thought that -Os would have done this job for free.
See above.