[LLVMdev] Why clang inlines with -O3 flag and opt doesn't?

Eli Friedman eli.friedman at gmail.com
Fri Sep 3 01:21:16 PDT 2010


On Fri, Sep 3, 2010 at 12:46 AM, Yuri <yuri at rawbw.com> wrote:
> When I compile my C fibonacci example fib.c with 'clang -O3 -c -emit-llvm -o fib-clang.bc fib.c&&  llvm-dis fib-clang.bc' I get fib-clang.ll that has some degree of inlining in it.
>
> But when I get an equivalent to fib.c file fib.ll and run it through opt with the command 'llvm-as fib.ll&&  opt -O3 fib.bc -o fib-opt.bc&&  llvm-dis fib-opt.bc' resulting fib-opt.ll doesn't have any degree of inlining despite the flag -O3.
>
> Why clang with the flag -O3 inlines code and opt with the same -O3 doesn't?
> How can I make opt inline my .ll code the same way?

Trunk clang and opt appear to completely refuse to inline the function
in question because it is recursive.  If you're using an earlier
version, I think opt might not be using exactly the same inlining
thresholds as clang...

-Eli




More information about the llvm-dev mailing list