Which optimization does LLVM perform?

我的梦境 提交于 2019-12-21 08:48:50

问题


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)


回答1:


why are there two lists?

Function and Module passes have their own pass managers and so print out separately.

is there any similar option for other tools, especially "clang"

With clang you can use -mllvm -debug-pass=Arguments.



来源:https://stackoverflow.com/questions/7656156/which-optimization-does-llvm-perform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!