<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">LLVM provides a facility to initialize a “standard” optimization pass pipeline in PassManagerBuilder, with multiple options (including the optimization level).</div><div class=""><br class=""></div><div class="">It is used in clang (clang/CodeGen/BackendUtil.cpp) or in opt.cpp (see AddOptimizationPasses()).</div><div class=""><br class=""></div><div class="">You can compare your pipeline to clang by trying: </div><div class=""><br class=""></div><div class="">echo "" | clang -x c - -mllvm -debug-pass=Structure -c</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 17, 2015, at 3:41 PM, Russell Wallace via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Given a generated module in memory, how do you run all available optimisations on it?</div><div class=""><br class=""></div><div class="">Tutorial section 4.3 at <a href="http://llvm.org/docs/tutorial/LangImpl4.html" class="">http://llvm.org/docs/tutorial/LangImpl4.html</a> picks out just a few optimisations, which makes sense for a JIT compiler on short running code, but I'm looking at long-running code where it would be worthwhile to start off applying all of them and possibly selectively disable any that turn out not to be useful.</div><div class=""><br class=""></div><div class="">C:\llvm\tools\opt\opt.cpp seems to be a program that runs optimisations from IR to IR, and perhaps runs all of the applicable ones; main() seems to contain a list of optimisation pass initialisations (though only the ones applicable where we aren't generating machine code yet). Would copy-pasting the code from that file be the right starting point?</div><div class=""><br class=""></div><div class="">On the other hand, if so, I would have expected that code to occur again in the clang source tree, because clang likewise has a -O3 option, but it doesn't seem to. That suggests to me that I'm confused about how things are organized. What am I missing?</div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>