Page MenuHomePhabricator

Add support for using pass plugins from lld
Needs ReviewPublic

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



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.

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.