[PATCH] D130889: [llvm] Introduce a pass plugin registry and loader
Philippe Virouleau via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 1 02:19:06 PDT 2022
viroulep created this revision.
viroulep added reviewers: w2yehia, mehdi_amini, pcc.
Herald added subscribers: ormris, steven_wu, hiraditya, arichardson, mgorny, emaste.
Herald added a reviewer: MaskRay.
Herald added a project: All.
viroulep requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, StephenFan.
Herald added projects: clang, LLVM.
This basically extends what has been done for opt in https://reviews.llvm.org/D121566.
The general issue is that, at the moment and except for opt, you can't use command line options defined by plugins when using only -load-pass-plugin (or -fpass-plugin), and you have to also load the library with the "old" entry point through -load to have them recognized.
This is due to the fact that parsing command line options occurs before plugins are loaded through -load-pass-plugin, and basically each tool has its own way of dealing with the loading of pass plugins.
The patch tries to mimic what was done for the existing `-load` command line option and aims at providing common entry points for the lib and tools:
- tools make sure to register the loaded plugin (through the option or manually)
- any part of the lib/tools can query the registry to have the plugins register their callbacks.
As a result -load-pass-plugin has a behavior that matches the -load option, and tools can simply include the header defining the -load-pass-plugin option if they want to have the feature.
I'm not exactly sure why -load-pass-plugin wasn't created with the same behavior as -load, which makes me think I may be missing something: if the implementation I suggest doesn't look good to you I'd be happy to look into something else (hopefully the general idea of having a single load for old/new plugins does sound good to you).
This patch touches a couple of tools (clang, llvm-lto2, opt) in addition to llvm; I tried to include only a couple of appropriate reviewers; my apologies if I missed someone, please feel free to add more relevant people if you think it's necessary!
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 19676 bytes
Desc: not available
More information about the cfe-commits