[NewPM] Don't error when there's an unrecognized pass name
authorArthur Eubanks <aeubanks@google.com>
Fri, 8 Jan 2021 04:20:46 +0000 (20:20 -0800)
committerArthur Eubanks <aeubanks@google.com>
Fri, 8 Jan 2021 06:33:32 +0000 (22:33 -0800)
This currently blocks --print-before/after with a legacy PM pass, for
example when we use the new PM for the optimization pipeline but the
legacy PM for the codegen pipeline. Also in the future when the codegen
pipeline works with the new PM there will be multiple places to specify
passes, so even when everything is using the new PM, there will still be
multiple places that can accept different pass names.

Reviewed By: hoy, ychen

Differential Revision: https://reviews.llvm.org/D94283

llvm/include/llvm/IR/PassInstrumentation.h
llvm/lib/IR/PassInstrumentation.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/print-before-after.ll

index 98b3fd4..291f324 100644 (file)
@@ -127,8 +127,6 @@ public:
   void addClassToPassName(StringRef ClassName, StringRef PassName);
   /// Get the pass name for a given pass class name.
   StringRef getPassNameForClassName(StringRef ClassName);
-  /// Whether or not the class to pass name map contains the pass name.
-  bool hasPassName(StringRef PassName);
 
 private:
   friend class PassInstrumentation;
index 6a2defc..56a36db 100644 (file)
@@ -22,14 +22,6 @@ void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
   ClassToPassName[ClassName] = PassName.str();
 }
 
-bool PassInstrumentationCallbacks::hasPassName(StringRef PassName) {
-  for (const auto &E : ClassToPassName) {
-    if (E.getValue() == PassName)
-      return true;
-  }
-  return false;
-}
-
 StringRef
 PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) {
   return ClassToPassName[ClassName];
index 8f6a96d..527d19d 100644 (file)
@@ -459,14 +459,6 @@ PassBuilder::PassBuilder(bool DebugLogging, TargetMachine *TM,
 #define CGSCC_ANALYSIS(NAME, CREATE_PASS)                                      \
   PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
 #include "PassRegistry.def"
-    for (const auto &P : printBeforePasses()) {
-      if (!PIC->hasPassName(P))
-        report_fatal_error("unrecognized pass name: " + P);
-    }
-    for (const auto &P : printAfterPasses()) {
-      if (!PIC->hasPassName(P))
-        report_fatal_error("unrecognized pass name: " + P);
-    }
   }
 }
 
index c0b929d..4197792 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
-; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
 ; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
 ; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
 ; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE