opt -O2 optimization passes

Hi all,

I would like to know which optimization passes are performed at -O2 by opt. So I used following command:

llvm-as < /dev/null | opt -O2 -std-compile-opts -disable-output -debug-pass=Arguments

I’ve got following output for LLVM opt 2.9:

Pass Arguments: -no-aa -tbaa -basicaa -simplifycfg -domtree -scalarrepl -early-cse
Pass Arguments: -targetlibinfo -no-aa -tbaa -basicaa -preverify -domtree -verify -lowersetjmp -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -inline -functionattrs -argpromotion -scalarrepl-ssa -domtree -early-cse -simplify-libcalls -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -instcombine -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -iv-users -indvars -loop-idiom -loop-deletion -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -adce -simplifycfg -strip-dead-prototypes -print-used-types -deadtypeelim -globaldce -constmerge -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -inline -functionattrs -scalarrepl-ssa -domtree -early-cse -simplify-libcalls -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -instcombine -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -iv-users -indvars -loop-idiom -loop-deletion -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -adce -simplifycfg -strip-dead-prototypes -print-used-types -deadtypeelim -constmerge -preverify -domtree -verify

Why is there two lines stating with ‘Pass Argument:’ ?

To reproduce opt-O2 behavior should I copy options from the two lines or only second one ?
Thanks for your answers
Best Regards
Seb

Hi Seb,

I would like to know which optimization passes are performed at -O2 by opt. So I
used following command:

llvm-as < /dev/null | opt -O2 -std-compile-opts -disable-output
-debug-pass=Arguments

first off, if you pass -O2 there is no need for -std-compile-opts and vice
versa.

I've got following output for LLVM opt 2.9:

Pass Arguments: -no-aa -tbaa -basicaa -simplifycfg -domtree -scalarrepl -early-cse
Pass Arguments: -targetlibinfo -no-aa -tbaa -basicaa -preverify -domtree

...

Why is there two lines stating with 'Pass Argument:' ?

This is coming from -O2. When a front-end outputs a function, it immediately
runs the per-function passes in the first line on it. This tends to shrink
functions a lot, reducing memory usage. When all of the functions have been
output all of the other passes are run.

To reproduce opt-O2 behavior should I copy options from the two lines or only
second one ?

Both of them. To be most accurate, you can do the following:

   opt bitcode.bc pass-list-from-first-line | opt pass-list-from-second line

Ciao, Duncan.