[cfe-dev] always_inline and noinline attributes

Eli Friedman eli.friedman at gmail.com
Tue Jul 22 08:11:26 PDT 2008


On Tue, Jul 22, 2008 at 12:08 AM, Matthijs Kooijman <matthijs at stdin.nl> wrote:
>> I'd strongly prefer to do this in the LLVM IR level instead of on clang
>> ASTs.
> That was the plan, AFAIU. Yet it would make sense to have clang do it at the
> end of its compilation (by running an inliner over the generated IR).
>
>> No, it should only happen within a translation unit.  The semantics of the
>> program should not change based on whether you're using LTO or not, and
>> inlining can sometimes change semantics for (arguably very broken) uses.
> At the very least, I would make it an option whether to strip the
> always_inline info after compiling a single translation unit, so people can
> explicitely choose to still do (forced) inlining at link time.

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.

In any case, the issue isn't whether to do inlining with LTO, but
whether to force inlining with LTO.

-Eli



More information about the cfe-dev mailing list