[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 09:54:13 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().PassPlugins) {
+ if (auto PassPlugin = llvm::PassPlugin::Load(Path)) {
+ PassPlugins.emplace_back(std::make_unique<llvm::PassPlugin>(*PassPlugin));
+ Clang->getPassPlugins().push_back(PassPlugins.back().get());
+ } else {
+ Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
+ << Path << toString(PassPlugin.takeError());
+ }
+ }
+
----------------
aengelke wrote:
llvm::PassPlugin::Load pulls in the LLVM Passes library, which pulls in almost all passes. I can do that, but then the clangFrontend library would have many more dependencies. clangFrontendTool already pulls these in through CodeGen etc., but clangFrontend users might not want that?
https://github.com/llvm/llvm-project/pull/171868
More information about the llvm-branch-commits
mailing list