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: -Os & inlining functions used only once



> 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.



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