[LLVMdev] Different results using -emit-llvm and llc together than just using -S?

Nick Lewycky nicholas at mxc.ca
Wed Mar 13 02:53:10 PDT 2013

Ryan Taylor wrote:
> Why would the generated assembly results for a piece of code be
> different if I did this:
> clang -S -emit-llvm sample.c -o sample.ll
> llc sample.ll -o sample.s
> then if I did this:
> clang -S sample.c -o sample.s

For one example, 'llc' defaults to -O2 but clang defaults to -O0. In 
general, clang sets up the equivalent of an opt|llc run with a slew of 
flags passed in. Also, note that clang -O0 is not the same as clang -O2 
-mllvm -disable-llvm-optzns, as clang chooses to emit more code which 
may prove useful to the optimizer, but would only waste time at -O0.


More information about the llvm-dev mailing list