[PATCH] D97810: [opt] Error if -debug-pass is specified alongside the new PM

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 2 14:53:53 PST 2021


aeubanks updated this revision to Diff 327599.
aeubanks added a comment.

add flag to use legacy PM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97810/new/

https://reviews.llvm.org/D97810

Files:
  llvm/include/llvm/IR/LegacyPassManager.h
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/test/Other/debug-pass-npm.ll
  llvm/tools/opt/opt.cpp


Index: llvm/tools/opt/opt.cpp
===================================================================
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -775,6 +775,12 @@
                 "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";
Index: llvm/test/Other/debug-pass-npm.ll
===================================================================
--- /dev/null
+++ 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
Index: llvm/lib/IR/LegacyPassManager.cpp
===================================================================
--- llvm/lib/IR/LegacyPassManager.cpp
+++ llvm/lib/IR/LegacyPassManager.cpp
@@ -242,6 +242,8 @@
 
 namespace llvm {
 namespace legacy {
+bool debugPassSpecified() { return PassDebugging != Disabled; }
+
 //===----------------------------------------------------------------------===//
 // FunctionPassManagerImpl
 //
Index: llvm/include/llvm/IR/LegacyPassManager.h
===================================================================
--- llvm/include/llvm/IR/LegacyPassManager.h
+++ llvm/include/llvm/IR/LegacyPassManager.h
@@ -26,6 +26,10 @@
 
 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;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97810.327599.patch
Type: text/x-patch
Size: 1887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210302/1064091a/attachment.bin>


More information about the llvm-commits mailing list