[llvm-dev] how to add my own passes to LTO pass

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 22 08:11:14 PDT 2020


On Wed, Apr 22, 2020 at 5:12 AM y liu via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Hi,
> I have a module pass and I hope to use it to optimize a real-world program.
> I need LTOļ¼Œand I have got LTO plugin.
>

Do you mean the LLVM gold plugin (relevant when doing LTO links with gold
or gnu ld), or are you trying to load your new pass via a pass plugin?


> But How can I add my passes to LTO Pass. I can't find solution.
> What should I do?
>

This depends on whether you are trying to add via a pass plugin dynamically
via the command line (I believe the support for this is work in progress),
or by manually modifying the pass pipeline within LLVM.
Have you implemented as an old pass manager pass (the current default) or
the new pass manager or both?
Is it an LTO specific pass, or do you also want to run for non-LTO
optimizing compiles (most optimizing passes should run in all cases).

Assuming the latter, and also assuming you are using the default old pass
manager, you would want to look at the following places in
PassManagerBuilder.cpp:

regular (full) LTO: PassManagerBuilder::addLTOOptimizationPasses

ThinLTO: PassManagerBuilder::populateModulePassManager, which is used both
by the pre-LTO compile and by the LTO linking ThinLTO compiles. If you want
to insert your pass for both, just put it in the relevant place in this
file, if you want to only do during the LTO link portion of the ThinLTO
compile, then guard it with a check for "PerformThinLTO".

For the new pass manager, it would be added to PassBuilder.cpp (that is
structured a bit differently so let me know and I can point you in the
right direction). If you are planning to send upstream it should be
supported by both pass managers.

HTH,
Teresa

_______________________________________________

> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>


-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200422/91ae6c6c/attachment.html>


More information about the llvm-dev mailing list