diff --git a/llvm/include/llvm/IR/LegacyPassManager.h b/llvm/include/llvm/IR/LegacyPassManager.h index 2b87143276b9a..2459f0a5450a0 100644 --- a/llvm/include/llvm/IR/LegacyPassManager.h +++ b/llvm/include/llvm/IR/LegacyPassManager.h @@ -26,6 +26,10 @@ class Module; namespace legacy { +// Whether or not -debug-pass has been specified. For use to check if it's +// specified alongside the new PM. +bool debugPassSpecified(); + class PassManagerImpl; class FunctionPassManagerImpl; diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 94be208617c50..32840fdeddf79 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -242,6 +242,8 @@ void PassManagerPrettyStackEntry::print(raw_ostream &OS) const { namespace llvm { namespace legacy { +bool debugPassSpecified() { return PassDebugging != Disabled; } + //===----------------------------------------------------------------------===// // FunctionPassManagerImpl // diff --git a/llvm/test/Other/debug-pass-npm.ll b/llvm/test/Other/debug-pass-npm.ll new file mode 100644 index 0000000000000..55c9baa6c5732 --- /dev/null +++ b/llvm/test/Other/debug-pass-npm.ll @@ -0,0 +1,4 @@ +; RUN: opt -enable-new-pm=0 -O1 %s -debug-pass=Structure +; RUN: not opt -enable-new-pm=1 -O1 %s -debug-pass=Structure 2>&1 | FileCheck %s + +; CHECK: does not work diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 48b0e397c9802..f690d5f1a789b 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -775,6 +775,12 @@ int main(int argc, char **argv) { "full list of passes, see the '--print-passes' flag.\n"; return 1; } + if (legacy::debugPassSpecified()) { + errs() + << "-debug-pass does not work with the new PM, either use " + "-debug-pass-manager, or use the legacy PM (-enable-new-pm=0)\n"; + return 1; + } if (PassPipeline.getNumOccurrences() > 0 && PassList.size() > 0) { errs() << "Cannot specify passes via both -foo-pass and --passes=foo-pass\n";