Russell Wallace via llvm-dev
2015-Sep-17 22:41 UTC
[llvm-dev] How to run all available optimisations
Given a generated module in memory, how do you run all available optimisations on it? Tutorial section 4.3 at http://llvm.org/docs/tutorial/LangImpl4.html 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. 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? 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? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150917/d5a51994/attachment.html>
Mehdi Amini via llvm-dev
2015-Sep-17 23:11 UTC
[llvm-dev] How to run all available optimisations
Hi, LLVM provides a facility to initialize a “standard” optimization pass pipeline in PassManagerBuilder, with multiple options (including the optimization level). It is used in clang (clang/CodeGen/BackendUtil.cpp) or in opt.cpp (see AddOptimizationPasses()). You can compare your pipeline to clang by trying: echo "" | clang -x c - -mllvm -debug-pass=Structure -c — Mehdi> On Sep 17, 2015, at 3:41 PM, Russell Wallace via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Given a generated module in memory, how do you run all available optimisations on it? > > Tutorial section 4.3 at http://llvm.org/docs/tutorial/LangImpl4.html <http://llvm.org/docs/tutorial/LangImpl4.html> 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. > > 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? > > 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? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150917/6d6f500f/attachment.html>