Skip to content

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

@white9ash

Description

@white9ash

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.:
PB.registerPipelineParsingCallback(
                    [](StringRef Name, FunctionPassManager &FPM,
                       ArrayRef<PassBuilder::PipelineElement> Inner) -> bool {
                         if (Name == "fla") {
                            FPM.addPass(FlatteningPass());
                            return true;
                        }  
                         return false;
                    });
  1. Compile and run:

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

  1. 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:

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions