Re: How does inline definitions affect inlining heuristics for C++?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28/10/12 14:12, Ulf Magnusson wrote:
> Hi,
>
> When not using whole program or link-time optimization, the body of a
> function must be available to the compiler for it to be able to inline
> calls the function when compiling a TU. Hence, you might want to put a
> function that is used in multiple TUs in a header file to give the
> compiler the opportunity to inline it. However, this forces you to
> make the function inline, as multiple definitions of non-inline
> functions is not allowed. It seems inline might be used for two
> different purposes here:
>
> (1) To make the function body available to the compiler to give it the
> opportunity to inline.
> (2) To give the compiler a hint to inline the function.
>
> But what if you trust the compiler to make the right decision for the
> function and don't want to influence the inlining heuristics? I.e.,
> what if you only want (1) and not (2)?
>
> Which brings me to my questions:
>
>  - How does making a function inline influence GCC's inlining
> heuristics for C++?
>  - If it does influence the inlining heuristics in some significant
> way, then is there some way to get (1) without (2) being forced upon
> you?
>
> (Oh, and please point out if I lied anywhere. :)
>
> Cheers,
> Ulf
I guess you may place the function in the common section so that both
instances can get coalesced.
Still, that's not something I'd encourage you to do.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux