[LLVMdev] inlining hint

Óscar Fuentes ofv at wanadoo.es
Thu Aug 27 13:54:32 PDT 2009


Dale Johannesen <dalej at apple.com> writes:

[snip]

> (It is also probably true that people who declare things inline in
> C/ObjC should be taken more seriously than those using C++; Apple's
> gcc has an adjustment to the inlining parameters that does this, which
> works well in practice on our code.)

If the user absolutely wants to inline a function, the `inline' keyword
is no solution. As Nick says on other message, he should use the
alwaysinline attribute.

`inline' as a hint saying "I'll like this to be inlined, but no hard
feelings if you don't" reflects either a shortcoming on the compiler or
a personality trait on the user. On what scenario it is useful to hint
the compiler about candidates for inlining, instead of requiring it?

OTOH I've seens lots of C++ code where `inline' is used everywhere for
no reason (a lot within class definions). Using it as a hint would
decrease the efficacy of the compiler's heuristics and actually produce
worse code.

-- 
Óscar




More information about the llvm-dev mailing list