[llvm] 99f1e86 - [opt] Error if -debug-pass is specified alongside the new PM
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 2 15:59:42 PST 2021
Author: Arthur Eubanks
Date: 2021-03-02T15:59:28-08:00
New Revision: 99f1e86cbb34b4a09fa422fe95e8f88f86360eab
URL: https://github.com/llvm/llvm-project/commit/99f1e86cbb34b4a09fa422fe95e8f88f86360eab
DIFF: https://github.com/llvm/llvm-project/commit/99f1e86cbb34b4a09fa422fe95e8f88f86360eab.diff
LOG: [opt] Error if -debug-pass is specified alongside the new PM
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D97810
Added:
llvm/test/Other/debug-pass-npm.ll
Modified:
llvm/include/llvm/IR/LegacyPassManager.h
llvm/lib/IR/LegacyPassManager.cpp
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/LegacyPassManager.h b/llvm/include/llvm/IR/LegacyPassManager.h
index 2b87143276b9..2459f0a5450a 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 94be208617c5..32840fdeddf7 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 000000000000..55c9baa6c573
--- /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 48b0e397c980..f690d5f1a789 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";
More information about the llvm-commits
mailing list