Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which optimization does LLVM perform?

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)

like image 462
Antoine Trouve Avatar asked Oct 05 '11 02:10

Antoine Trouve


People also ask

What is LLVM optimization?

A frontend that converts source code into an intermediate representation (IR). A target-independent optimization pipeline: a sequence of passes that successively rewrite the IR to eliminate inefficiencies and forms that cannot be readily translated into machine code. Sometimes called the “middle end.”

What architecture does LLVM support?

LLVM currently supports compiling of Ada, C, C++, D, Delphi, Fortran, Haskell, Julia, Objective-C, Rust, and Swift using various front ends.

What does link time optimization do?

What is Link Time Optimization (LTO) Link Time Optimization is a form of interprocedural optimization that is performed at the time of linking application code. Without LTO, Arm® Compiler for Linux compiles and optimizes each source file independently of one another, then links them to form the executable.

Does LTO improve performance?

Device LTO brings the performance advantages of device code optimization that were only possible in the nvcc whole program compilation mode to the nvcc separate compilation mode, which was introduced in CUDA 5.0.


1 Answers

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.

like image 51
echristo Avatar answered Nov 04 '22 01:11

echristo