[LLVMdev] Optimization application by llvm-gcc, opt

Duncan Sands baldrick at free.fr
Tue Dec 13 02:46:23 PST 2011

Hi RaghuB,

> I wanted to clarify something about the application of optimizations by llvm-gcc, opt and llc.
> Will the following two sequences generate the same optimized bitcode?
>     a) $ llvm-gcc -O3 -c -emit-llvm foo.c  -o foo.bc
>     b) $ llvm-gcc -O0 -c -emit-llvm foo.c -o foo.bc
>        $ opt -O3 foo.bc

not necessarily, though usually it is the same.  One reason for this is that
the per-function passes run by llvm-gcc are used to clean up functions as they
are output, while with opt they are run after the entire module has been
generated.  The difference is that when a function is output some things like
global variables may have only been partially output (eg may not have an initial
value yet) resulting in less or different optimization.

Ciao, Duncan.

More information about the llvm-dev mailing list