2 ms·
Looking at the big picture raised one question for me: how does LLVM deal with dependencies between optimization passes? It is well-known, for example, that th
by akkartik 15y ago
Looking at the big picture raised one question for me: how does LLVM deal with dependencies between optimization passes?
It is well-known, for example, that the whether you do register allocation before or after instruction scheduling can have huge implications for performance. Some programs prefer scheduling done earlier, and some prefer it later. gcc's optimization flags switch phase orderings among other things.
Does LLVM have any abstractions for managing phase orderings and intelligently picking between them? Or must the optimization classes be manually instantiated in the right order?
- Someone 15y agoLLVM leaves that problem for users of the library. Users instantiate optimization passes and specify in what order to call them. For example, 'opt' has (http://llvm.org/cmds/opt.html http://llvm.org/cmds/opt.html): -{passname} opt provides the ability to run any of LLVM's optimization or analysis passes in any order. The -help option lists all the passes available. The order in which the options occur on the command line are the order in which they are executed (within pass constraints). -std-compile-opts This is short hand for a standard list of compile time optimization passes. This is typically used to optimize the output from the llvm-gcc front end. It might be useful for other front end compilers as well. To discover the full set of options available, use the following command: llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments I do not know whether compilers 'included' with LLVM (clang, llvm_gcc) have support for tweaking the order. If they do not, you can always let them write unoptimized IR, and pipe the output through opt.