I would like concretely to know what does the various optimizations levels of LLVM correspond to.
That is to say, I would like to know which optimization passes are EXACTLY executed (outside the frontend) and in which order when I use the "-0x" options of llvm (or clang or opt). The "man" of the corresponding tools do not provide much information on this matter (to the oposite of gcc's one).
I am aware of this useful page: http://llvm.org/docs/Passes.html, but it does not provide any information regarding the "-Ox" options. I was looking for some debugging or verbose options (esp. using informations from "opt --help") but I couldn't find any useful option.
As a complement, I noticed by parsing the code that all various LLVM tools as well as clang use distinct drivers which parse options their own way. Are all those drivers similar with respect to the "-Ox" options ?
Edit: I found the option "-debug-pass=Arguments" for the "opt" tool, which gives the following output for option "O1":
Pass Arguments: -targetdata -no-aa -tbaa -targetlibinfo -basicaa -simplifycfg -domtree -scalarrepl -early-cse -lower-expect
Pass Arguments: -targetlibinfo -targetdata -no-aa -tbaa -basicaa -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -always-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 -memdep -memcpyopt -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -adce -simplifycfg -instcombine -strip-dead-prototypes -preverify -domtree -verify
This is close from what I wanted but remains two questions:
why are there two lists ?
is there any similar option for other tools, especially "clang" ? (according to my tests, "-debug-pass=Arguments" does not work with clang)
Edit: the option "-debug-pass=Structure" for the tool "opt" gives even more user friendly data (from http://llvm.org/docs/WritingAnLLVMPass.html)
Function and Module passes have their own pass managers and so print out separately.
With clang you can use -mllvm -debug-pass=Arguments.