[all-commits] [llvm/llvm-project] 3084a8: [Plugins] Add -plugin-arg and PassPluginLibraryInf...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Sep 29 11:59:29 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3084a8ffb386822a584f4658d8351a24aa3d965e
      https://github.com/llvm/llvm-project/commit/3084a8ffb386822a584f4658d8351a24aa3d965e
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M llvm/docs/NewPassManager.md
    M llvm/docs/ReleaseNotes.md
    M llvm/examples/Bye/Bye.cpp
    M llvm/examples/IRTransforms/SimplifyCFG.cpp
    M llvm/include/llvm/Plugins/PassPlugin.h
    M llvm/lib/Plugins/PassPlugin.cpp
    M llvm/test/Feature/codegen-plugin-passes.mir
    M llvm/test/Feature/codegen-plugin.ll
    M llvm/test/Feature/load_extension.ll
    M llvm/tools/llc/lib/llcdriver.cpp
    M llvm/tools/opt/NewPMDriver.cpp
    M llvm/tools/opt/NewPMDriver.h
    M llvm/tools/opt/optdriver.cpp
    M polly/lib/Support/RegisterPasses.cpp

  Log Message:
  -----------
  [Plugins] Add -plugin-arg and PassPluginLibraryInfo::ParseArguments (#227414)

opt and llc load -load-pass-plugin plugins from a cl::opt callback while
parsing argv, so that the options a plugin registers are recognized
later on the command line. cl::callback is to be removed to enable
migration to a TableGen-based option representation

(https://discourse.llvm.org/t/rfc-declare-library-command-line-options-in-tablegen-one-struct-per-library/91877/5).
To prepare for loading plugins after parsing, give plugins their own
arguments.

Add `-plugin-arg=<plugin>,<arg>`, which passes <arg> (split at the first
comma, so it may contain commas) to the new
PassPluginLibraryInfo::ParseArguments callback of the plugin named
<plugin> (LLVM_PLUGIN_API_VERSION 3). Plugins that define cl::opt (Polly
and the Bye and IRTransforms examples) parse their arguments with the
new parsePassPluginCommandLine.

opt also passes -plugin-arg arguments to statically linked extensions
(Extension.def), so Polly's options have the same spelling in both build
modes:

```
opt -plugin-arg=Polly,-polly-tile-sizes=1,64 ...                                 # linked
opt -load-pass-plugin=LLVMPolly.so -plugin-arg=Polly,-polly-tile-sizes=1,64 ...  # plugin
```

opt now registers plugins and linked extensions in one loop, so
optMain's PassBuilderCallbacks run after linked extensions.

Extracted from #226773



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list