llvm / llvm/llvm-project

clang does not recognize '-passes' argument when used with '-fpass-plugin' (works in opt)

Open
#167,445 1 comment 0 reactions 0 assignees View on GitHub
clang:driver
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### Description
When using `clang` or `clang-cl` to invoke an LLVM pass plugin built for the new Pass Manager,
the `-passes` option (passed via `-mllvm`) is not recognized.
However, the same plugin works correctly with `opt -load-pass-plugin -passes="..."`.

### Steps to reproduce
1. Build any new-PM compatible pass plugin, e.g.:
~~~CPP
PB.registerPipelineParsingCallback(
[](StringRef Name, FunctionPassManager &FPM,
ArrayRef Inner) -> bool {
if (Name == "fla") {
FPM.addPass(FlatteningPass());
return true;
}
return false;
});
~~~

2. Compile and run:

`clang -O1 -fpass-plugin=build/MyPass.dll -mllvm -passes="fla" main.cpp`

3. Output:

clang (LLVM option parsing): Unknown command line argument '-passes=fla'. Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--pgso=fla'?

Running the same plugin with opt works fine:

4. `opt -load-pass-plugin=build/MyPass.dll -passes="fla" test.bc -o out.bc`

Does clang support the new PassManager '-passes=' pipeline like opt?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.