LTO and the inlining of functions only called once.
Richard Guenther
richard.guenther@gmail.com
Sat Oct 10 11:34:00 GMT 2009
On Sat, Oct 10, 2009 at 12:55 PM, Toon Moene <toon@moene.org> wrote:
> Gcc's man page says:
>
> -finline-functions-called-once
> Consider all "static" functions called once for inlining into
> their caller even if they are not marked "inline". If a call
> to a given function is integrated, then the function is not
> output as assembler code in its own right.
>
> Enabled at levels -O1, -O2, -O3 and -Os.
>
> Now, when using -flto -fwhole-program, *all* functions (that the user
> provided) will be "static inline", no ? - so *all* functions only called
> once in that program will be inlined ?
Well, I think that we should try to not do this across the whole program.
Simply for the reason that a gigantic main function will hit several
non-linear complexity algorithms in GCC.
> I am asking because our most important programs often consist of a chain of
> "routines-that-do-all-the-work" which are all only called once. However, in
> general they are (certainly when viewed from the perspective of a C
> programmer) *huge*.
>
> E.g., our forecast program:
>
> HLPROG (small "main" program)
> |
> | calls
> V
> GEMINI (read input files, write output files, and:)
> |
> V
> SL2TIM (time stepping, and:)
> |
> V
> PHCALL (subgrid scale computations)
> |
> V
> PHTASK (split them into tasks over model domain)
> |
> V
> PHYS (actually hand out the work to:)
> |
> ----------------------
> | | | | |
> LSP CVP RADIA TURB SOIL
>
> (large scale precipitation, convective precipitation,
> radiation, turbulence, soil processes)
>
> The last five are each around 2,000 lines of Fortran, the P routines are
> each several hundreds of lines, as is SL2TIM. GEMINI is more than 2,000
> lines.
>
> My question is: How can I be sure that all of them are integrated (note that
> the man page says they are "considered") ? Does -Winline help here ?
> Perhaps I should scan the assembler output (HAH!).
-Winline doesn't help here. Scanning the assember output does (obviously!).
Note that I wouldn't expect such aggressive inlining to have any positive
performance impact - were it not for the fact that we still lack a properly
operating IPA points-to analysis pass (yes, it's on my todo list - but
not for 4.5).
Richard.
More information about the Gcc
mailing list