[cfe-dev] How to inline a C-function during code generation ?

Nat! nat at mulle-kybernetik.com
Mon May 25 11:05:06 PDT 2015


Hi

I started hacking on clang itself and I have some questions, that I couldn't figure out with the help of the source code or the documentation. 

Looking at the IR code generated by -O2 and -O0 it seems, that function inlining is done in clang already. But I haven't figured out, how that is actually done. 

What I want to do is - during code generation - something to the effect of calling "GetOrCreateLLVMFunction" and then doing an "EmitCall", but getting the function body inlined instead of a regular call. The function is a static inline C function, it has a known name and known argument/return types, and it would be an error, if that function is not available at that point (or maybe even not declared static inline). GetOrCreateLLVMFunction and EmitCall does not seem to do the work for me, as I hoped. The function is never inlined, regardless of optimization level. The same function is inlined by the compiler itself, with no problem, within the source code itself.

So how can I do that ?

Ciao
   Nat!
------------------------------------------------------
Just because nobody understands you 
does not mean you’re an artist. -- DLR





More information about the cfe-dev mailing list