[LLVMdev] function inlining of llvm-gcc versus gcc, and llvm-g++ versus g++?
baldrick at free.fr
Fri Jan 29 00:35:16 PST 2010
> Does llvm-gcc do more, less, or the same amount of function inlining as
> gcc? What about llvm-g++ and g++?
this is a hard question to answer, since it depends hugely on what the code
being compiled is and what versions of gcc and LLVM you are using. The gcc
developers work actively on the inliner, and it has changed hugely between
(say) gcc-4.2 and the latest version of gcc. The changes to the LLVM inliner
between versions have been less dramatic, but nonetheless significant. My
understanding is that typically the latest llvm-gcc inlines less than gcc-4.2;
I don't know how it compares to gcc-4.5. I suggest you experiment yourself.
> I am specifically interested in inlining that occurs when I run with the
> --emit-llvm command line flag like this:
> llvm-gcc -c --emit-llvm foo.c
No inlining occurs when you run like that because you didn't specify
an optimization level. If you want the maximum amount of inlining
try adding -O3 to the command line. You will also get some inlining
at lower optimization levels (including -Os).
> thus generating bitcode. That is, I am not interested at this moment in
> what happens when I run the opt or llc tools
> on the bit code after its omitted, I am just focusing on the inlining
> that has occurred up until the point that the bitcode
> is emitted.
It used to be that if you specified (eg) -O2 then the gcc parts of llvm-gcc
would do some inlining before the gcc -> llvm conversion kicked in. I'm pretty
sure this was already no longer the case in llvm-gcc from the LLVM 2.6 release,
i.e. all inlining is now done by the LLVM optimizers. You can do this:
llvm-gcc -c --emit-llvm foo.c -O3 -mllvm -disable-llvm-optzns
to see the bitcode without LLVM optimizations, and
llvm-gcc -c --emit-llvm foo.c -O3
to see it with optimization.
More information about the llvm-dev