[cfe-dev] always_inline and noinline attributes

Matthijs Kooijman matthijs at stdin.nl
Fri Jun 20 05:15:19 PDT 2008


Hi All,

for our compiler, we could very much use the always_inline attribute to force
a function to be inlined. Currently, we have a local hack that always inlines
functions marked "inline" (by giving them linkonce linkage and inline all
linkonce functions), but that's not really the way to go.

Gcc and llvm-gcc support the always_inline attribute for exactly this reason.
Clang currently completely ignores this attribute. What would we the correct
way of implementing this?

Currently, llvm-gcc supports always_inline by inlining those functions in the
gcc part, even before the llvm inliner comes along to look at the program. We
could take a similar approach in clang, though it seems like double work to
me. Perhaps it would be better to take a route similar to what the noinline
attribute does in llvm-gcc: Output a global variable in the llvm.metadata
section with a list of all the force_inline functions. This ensures we can
reuse the llvm inliner and could also be useful for other frontends. Any
details I'm missing?

Furthermore, I was also looking at the "noinline" attribute (mainly as an
example). It seems that llvm-gcc emits a llvm.noinline global variable
containing references to functions with the noinline attribute. Clang however,
parses the noinline keyword, but does not emit anything for it. Is this
intentional, or did nobody get around to writing this yet?

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080620/db8d5918/attachment.sig>


More information about the cfe-dev mailing list