<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 25, 2015 at 11:05 AM, Nat! <span dir="ltr"><<a href="mailto:nat@mulle-kybernetik.com" target="_blank">nat@mulle-kybernetik.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
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.<br>
<br>
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.<br></blockquote><div><br>Here's some useful terminology for this discussion:<br><br>IRGen: Clang's generation of LLVM IR from Clang ASTs</div><div>CodeGen: LLVM's generation of machine code/assembly from LLVM IR<br>Clang: The Clang frontend, down to the point that it generates and passes LLVM IR to the LLVM libraries.<br>LLVM: Everything else. (the middle and backend)<br><br>Clang does not do inlining.<br>LLVM does inlining.<br>Clang produces code that can be/is encouraged to be/is required to be inlined by LLVM.<br><br>For example, if the user writes source code with the always_inline (or is it "alwaysinline", I forget) attribute, then Clang produces LLVM IR with the matching attribute and LLVM obeys the request (where possibly) and inlines all calls to that function during LLVM's optimization passes.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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.<br>
<br>
So how can I do that ?<br>
<br>
Ciao<br>
   Nat!<br>
------------------------------------------------------<br>
Just because nobody understands you<br>
does not mean you’re an artist. -- DLR<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>