MaskRay wrote:
Revised based on the review. The interface is now:
```
opt -load-pass-plugin=Bye.so -plugin-arg=Bye,-wave-goodbye -passes=goodbye a.ll
opt -load-pass-plugin=LLVMPolly.so -plugin-arg=Polly,-polly-tile-sizes=64,1 ...
```
- `-load-pass-plugin=<file>` is a plain path, which may contain commas. opt,
llc, and clang-linker-wrapper load plugins after `cl::ParseCommandLineOptions`,
so a loaded plugin's options are no longer accepted as ordinary options.
- `-plugin-arg=<plugin>,<arg>` is split at the first comma, so `<arg>` may
contain commas. The arguments go, in order, to the new
`PassPluginLibraryInfo::ParseArguments` callback of the plugin with that name
(`LLVM_PLUGIN_API_VERSIONĀ 3`). PassPlugin itself no longer calls cl::; plugins
that define cl::opt (Bye, IRTransforms, Polly) call cl::ParseCommandLineOptions
from the callback.
- Polly is migrated: `%{polly,}` expands to `-plugin-arg=Polly`, when Polly is
a plugin and to nothing when it is linked into tools, where its options stay
global. check-polly passes in both configurations (1137 linked, 1136 with
LLVM_POLLY_LINK_INTO_TOOLS=OFF).
- -load-pass-plugin=<file> is a plain path again (commas in paths work as on
main, and clang/flang/LTO are unchanged). opt, llc, and clang-linker-wrapper
load plugins after cl::ParseCommandLineOptions, so a loaded plugin's options
are no longer accepted as ordinary options.
- -plugin-arg=<plugin>,<arg> is split at the first comma only, so values may
contain commas. All arguments naming a plugin are collected in command-line
order and passed in one call to that plugin's ParseArguments callback. This
mirrors clang's frontend plugins: clang -fplugin=foo.so -fplugin-arg-foo-<arg>,
which the driver turns into cc1 -load foo.so -plugin-arg-foo <arg>. The plugin
name moves into the value because a cl:: option can't have the plugin name in
its spelling.
- PassPlugin itself no longer calls cl::. Plugins that define cl::opt (Bye,
IRTransforms, Polly) call cl::ParseCommandLineOptions from the callback.
- PassPluginLibraryInfo gains Error `(*ParseArguments)(ArrayRef<const char *>)`
after PreCodeGenCallback, so LLVM_PLUGIN_API_VERSION goes from 2 to 3, as its
comment requires when callbacks are added. A plugin built against the old
header is rejected with `Wrong API version on plugin '...'. Got version 2,
supported version is 3`.
- Polly is migrated. In tests, each Polly option is prefixed with %{polly,},
which expands to `-plugin-arg=Polly,` when Polly is a plugin and to nothing
when Polly is linked into tools, where its options stay global.
## Polly
```
; RUN: opt %loadNPMPolly %{polly,}-polly-tile-sizes=1,64
'-passes=polly-custom<opt-isl;ast>' %{polly,}-polly-print-ast -disable-output <
%s | FileCheck %s
```
Linked into tools (unchanged from before):
```
opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names
-polly-import-jscop-dir=.../ScheduleOptimizer -polly-codegen-verify
-polly-tile-sizes=1,64 '-passes=polly-custom<opt-isl;ast>' -polly-print-ast
-disable-output
```
As a plugin:
```
opt -load-pass-plugin=.../lib/LLVMPolly.so
-plugin-arg=Polly,-polly-process-unprofitable
-plugin-arg=Polly,-polly-remarks-minimal
-plugin-arg=Polly,-polly-use-llvm-names
-plugin-arg=Polly,-polly-import-jscop-dir=.../ScheduleOptimizer
-plugin-arg=Polly,-polly-codegen-verify
-plugin-arg=Polly,-polly-tile-sizes=1,64
'-passes=polly-custom<opt-isl;ast>' -plugin-arg=Polly,-polly-print-ast
-disable-output
```
https://github.com/llvm/llvm-project/pull/226773
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits