diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1179,6 +1179,14 @@ TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr); setCommandLineOpts(CodeGenOpts); + if (llvm::legacy::debugPassSpecified()) { + llvm::errs() + << "-debug-pass/-fdebug-pass-* does not work with the new pass manager " + "for the middle-end optimization pipeline, either use " + "-fdebug-pass-manager, or use the legacy PM " + "(-flegacy-pass-manager)\n"; + } + bool RequiresCodeGen = (Action != Backend_EmitNothing && Action != Backend_EmitBC && Action != Backend_EmitLL); diff --git a/clang/test/Misc/debug-pass-npm.c b/clang/test/Misc/debug-pass-npm.c new file mode 100644 --- /dev/null +++ b/clang/test/Misc/debug-pass-npm.c @@ -0,0 +1,8 @@ +// RUN: %clang -fexperimental-new-pass-manager %s -c -o /dev/null -mllvm -debug-pass=Structure 2>&1 | FileCheck %s +// RUN: %clang -fexperimental-new-pass-manager %s -c -o /dev/null -fdebug-pass-arguments 2>&1 | FileCheck %s +// RUN: %clang -flegacy-pass-manager %s -c -o /dev/null -fdebug-pass-arguments 2>&1 | FileCheck %s --check-prefix=LPM + +void foo() {} + +// CHECK: does not work +// LPM-NOT: does not work