[llvm-branch-commits] [clang] [Clang] Load pass plugins before parsing LLVM options (PR #171868)
Alexis Engelke via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 15 04:38:18 PST 2025
================
@@ -233,6 +234,20 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
Clang->LoadRequestedPlugins();
+ // Load and store pass plugins for the back-end. Store the loaded pass plugins
+ // here and store references to these in CodeGenOpts to avoid pulling in the
+ // entire PassPlugin dependency chain in CodeGenOpts.
+ std::vector<std::unique_ptr<llvm::PassPlugin>> PassPlugins;
+ for (const std::string &Path : Clang->getCodeGenOpts().PassPluginNames) {
----------------
aengelke wrote:
> we can wrap them in some frontend plugin adapter and have some plugin uniformity in clang.
Could you share some more details on how you envision this? Because loading the backend plugins has to happen somewhere in or under ExecuteCompilerInvocation before llvm::cl::ParseCommandLineOptions is called. So there're two options:
1. Call the backend plugin wrapper here and prepopualte the FrontendPluginRegistry with it. From the FrontendPluginRegistry, at this point only instantiate is called, where there's no access to the CompilerInstance. I don't see how this is viable.
2. Move llvm::cl::ParseCommandLineOptions down into CodeGenAction, which might cause some breakage due to changing options. -fpass-plugin would still need to be handled somewhere before that and this does need some extra code somewhere?
https://github.com/llvm/llvm-project/pull/171868
More information about the llvm-branch-commits
mailing list