This is an archive of the discontinued LLVM Phabricator instance.

Add support for using pass plugins from lld
AbandonedPublic

Authored by daniel_a on Sep 21 2019, 4:52 AM.

Details

Summary

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 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.

Diff Detail

Event Timeline

daniel_a created this revision.Sep 21 2019, 4:52 AM

Adding people who knows more about LTO than me as reviewers...

daniel_a marked an inline comment as done.Sep 25 2019, 12:25 AM
daniel_a added inline comments.
lld/tools/lld/CMakeLists.txt
4

I think we need to add set(LLVM_NO_DEAD_STRIP 1) here as well, otherwise plugins won’t necessarily find the symbols they need.

daniel_a abandoned this revision.Apr 22 2021, 11:43 AM

I’m closing this since there’s been no activity on the patch at all since I opened it. It would be a change that would be helpful for any researcher trying to improve LTO in LLVM, but if the project isn’t interested then there’s nothing much to do, and after more than one and a half years of silence it’s hard to believe that the project would be interested.