[llvm-dev] Easy way to add common pass for optimization

John Brawn via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 15 05:39:43 PDT 2019

It depends on if you’re using the new or old pass managers, though if you’re following that tutorial you’re probably using the old
one (looking at https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.html#llvm-optimization-passes).

If so then you can use PassManagerBuilder (http://llvm.org/doxygen/classllvm_1_1PassManagerBuilder.html). It may be also
worthwhile looking at what opt does (AddOptimizationLevel.cpp in opt.cpp) as it uses PassManagerBuilder but does something
a bit more complex than just setting the optlevel then populating the pass manager (but maybe just setting optlevel is all you
need for your purposes).


From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Yafei Liu via llvm-dev
Sent: 15 October 2019 09:54
To: llvm-dev
Subject: [llvm-dev] Easy way to add common pass for optimization

Hi all,
I wrote a compiler front end which generates IR codes, but due to the logic, the IR codes have a lot of  instructions like unnecessary br jump, basic block creation, load instructions and expression which can be simplified.
now I want to use built in passes to optimize the generated code, but after I read the tutorial: https://llvm.org/docs/tutorial/MyFirstLanguageFrontend, I found that I have to add passess one by one, on function level.

I know these passes for module level, but I don't know what passes I should add, and I do not have special optimization requirements, so built-in passes will meet my requirements, So this there any easy way to add most common passes which all compilers will probable used?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191015/5933390d/attachment.html>

More information about the llvm-dev mailing list