[PATCH] D67876: Add support for using pass plugins from lld

Daniel Ashhami via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 04:52:13 PDT 2019


daniel_a created this revision.
daniel_a added reviewers: ruiu, chandlerc.
daniel_a added projects: LLVM, lld.
Herald added subscribers: llvm-commits, dang, dexonsmith, steven_wu, MaskRay, hiraditya, arichardson, mgorny, emaste.
Herald added a reviewer: espindola.

This commit adds support for using new-style pass manager pass plugins from lld.

The commit touches some different parts of the source tree, mainly a configuration option is added to libLTO where an optional list of new-style pass plugins are added. If that list (vector) isn't empty and the user has requested to use a custom pass pipeline, then the pass plugins will be loaded into the passbuilder, using the same code as opt uses when loading custom passes.

Then lld is modified to take a new command line parameter `--lto-newpm-load-pass-plugin` which can be given multiple times to make lld load a pass plugin.

I also had to modify the CMakeLists.txt of lld to export its symbols for dynamic linking.

To be able to add tests for this functionality I had to add a sample new-style pass to `llvm/lib/Transforms/HelloNewPM`. The code for that plugin is taken from the article Writing an LLVM Pass in 2018 <https://medium.com/@mshockwave/writing-llvm-pass-in-2018-part-i-531c700e85eb> written by Minh-Yi Hsu,

I also added a test for opts loading of new pass plugins, since it didn't have one.

Of course I'm open to splitting the changes into different ones, but since I didn't want to send a patch without adding tests I made a larger patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D67876

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  lld/test/ELF/lto/ltopasses-load-plugin.ll
  lld/test/lit.cfg.py
  lld/test/lit.site.cfg.py.in
  lld/tools/lld/CMakeLists.txt
  llvm/include/llvm/LTO/Config.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/CMakeLists.txt
  llvm/lib/Transforms/HelloNewPM/CMakeLists.txt
  llvm/lib/Transforms/HelloNewPM/HelloNewPM.cpp
  llvm/test/Feature/load_module_newpm.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67876.221168.patch
Type: text/x-patch
Size: 10514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190921/278aec02/attachment.bin>


More information about the llvm-commits mailing list