title: Which optimization does LLVM perform?
body: <p>I would like concretely to know what does the various optimizations levels of LLVM correspond to.</p>
  
  <p>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).</p>
  
  <p>I am aware of this useful page: <a href="http://llvm.org/docs/Passes.html">http://llvm.org/docs/Passes.html</a>, 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.</p>
  
  <p>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 ?</p>
  
  <p><strong>Edit</strong>: I found the option "-debug-pass=Arguments" for the "opt" tool, which gives the following output for option "O1":</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This is close from what I wanted but remains two questions:</p>
  
  <ul>
  <li><p>why are there two lists ?</p></li>
  <li><p>is there any similar option for other tools, especially "clang" ? (according to my tests, "-debug-pass=Arguments" does not work with clang)</p></li>
  </ul>
  
  <p><strong>Edit</strong>: the option "-debug-pass=Structure" for the tool "opt" gives even more user friendly data (from <a href="http://llvm.org/docs/WritingAnLLVMPass.html">http://llvm.org/docs/WritingAnLLVMPass.html</a>)</p>