[cfe-dev] always_inline and noinline attributes
eli.friedman at gmail.com
Tue Jul 22 17:10:49 PDT 2008
On Tue, Jul 22, 2008 at 10:38 AM, Devang Patel <dpatel at apple.com> wrote:
> On Jul 22, 2008, at 8:11 AM, Eli Friedman wrote:
>> Unless I'm mistaking the semantics of always_inline, it should be a
>> compile-time error to take the address of an always_inline function,
>> and always_inline functions shouldn't be exposed as external symbols.
>> Otherwise, it's impossible for the compiler to honor the
>> "always_inline" attribute.
> 1) inlining a function and 2) throwing away a function definition when
> function is inlined at all call sites are two separate operations.
> always_inline does not enforce 2) and always_inline does change symbol
Oh... okay, thanks for clarifying. That said, it seems sort of silly.
If the function can't be removed, doesn't always_inline just force
the compiler to bloat the code?
Is there some attribute that would enforce throwing away the
definition? If not, would it be useful to add one? Or is
always_inline along with static generally good enough?
> In gcc, -fvisibility-inlines-hidden enforces what you're describing.
That isn't quite the same thing; it affects all inlines, and it
doesn't prevent taking the address.
More information about the cfe-dev