[cfe-dev] always_inline and noinline attributes
dpatel at apple.com
Wed Jun 25 14:29:38 PDT 2008
On Jun 20, 2008, at 5:15 AM, Matthijs Kooijman wrote:
> 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
> way of implementing this?
The correct approach is to encode these function properties in LLVM
IR. Stay tuned, I'll send out proposal on LLVM dev list in next few
Once the information is encoded in the IR, the remaining issue is how
to invoke the LLVM inlining pass when at least one function is marked
as always_inline. There are two possible approaches:
1) Teach FE tools (e.g. clang, llvm-gcc) to insert inlining pass in
the PassManager while requesting (opt + code generation) when it least
one function with attribute always_inline is seen.
2) Teach the LLVM PassManager to sniff always_inline property encoded
in the LLVM IR and do the right thing.
I prefer 2), but would be OK with 1) until 2) is ready.
More information about the cfe-dev