[Mlir-commits] [mlir] d98481a - Revert "[MLIR] Provide a way to print ops in custom form on pass failure"

Mehdi Amini llvmlistbot at llvm.org
Sun Apr 17 11:55:46 PDT 2022


Author: Mehdi Amini
Date: 2022-04-17T18:55:09Z
New Revision: d98481a1e782a3bd2bd19df7e9cbb1e4d06416bf

URL: https://github.com/llvm/llvm-project/commit/d98481a1e782a3bd2bd19df7e9cbb1e4d06416bf
DIFF: https://github.com/llvm/llvm-project/commit/d98481a1e782a3bd2bd19df7e9cbb1e4d06416bf.diff

LOG: Revert "[MLIR] Provide a way to print ops in custom form on pass failure"

This reverts commit daabcf5f04bbd13ac53f76ca3cc43b0d1ef64f5a.

This patch still had on-going discussion that should be closed before
committing.

Added: 
    

Modified: 
    mlir/include/mlir/Pass/PassManager.h
    mlir/lib/Pass/IRPrinting.cpp
    mlir/lib/Pass/PassManagerOptions.cpp
    mlir/test/Pass/ir-printing.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h
index a6df1bb69aa16..13b127c360f15 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -253,15 +253,11 @@ class PassManager : public OpPassManager {
     ///   pass, we only print in the case of a failure.
     ///     - This option should *not* be used with the other `printAfter` flags
     ///       above.
-    /// * 'printCustomFormOnFailure' signals that when printing the IR after a
-    ///   pass failure, the custom form should be used (unsafe) instead of the
-    ///   generic form.
     /// * 'opPrintingFlags' sets up the printing flags to use when printing the
     ///   IR.
     explicit IRPrinterConfig(
         bool printModuleScope = false, bool printAfterOnlyOnChange = false,
         bool printAfterOnlyOnFailure = false,
-        bool printCustomFormOnFailure = false,
         OpPrintingFlags opPrintingFlags = OpPrintingFlags());
     virtual ~IRPrinterConfig();
 
@@ -292,13 +288,6 @@ class PassManager : public OpPassManager {
       return printAfterOnlyOnFailure;
     }
 
-    /// Returns true if the IR should be printed in custom form even on failure.
-    /// This is unsafe and there is no guaranee that the custom form printer
-    /// will not crash or print valid IR.
-    bool shouldPrintCustomFormOnFailure() const {
-      return printCustomFormOnFailure;
-    }
-
     /// Returns the printing flags to be used to print the IR.
     OpPrintingFlags getOpPrintingFlags() const { return opPrintingFlags; }
 
@@ -314,10 +303,6 @@ class PassManager : public OpPassManager {
     /// the pass failed.
     bool printAfterOnlyOnFailure;
 
-    /// A flag that indicates that the IR should be printed (or attempted to be
-    /// printed) in custom form even after a pass failure.
-    bool printCustomFormOnFailure;
-
     /// Flags to control printing behavior.
     OpPrintingFlags opPrintingFlags;
   };
@@ -340,9 +325,6 @@ class PassManager : public OpPassManager {
   ///   pass, we only print in the case of a failure.
   ///     - This option should *not* be used with the other `printAfter` flags
   ///       above.
-  /// * 'printCustomFormOnFailure' signals that when printing the IR after a
-  ///   pass failure, the custom form should be used (unsafe) instead of the
-  ///   generic form.
   /// * 'out' corresponds to the stream to output the printed IR to.
   /// * 'opPrintingFlags' sets up the printing flags to use when printing the
   ///   IR.
@@ -352,8 +334,7 @@ class PassManager : public OpPassManager {
       std::function<bool(Pass *, Operation *)> shouldPrintAfterPass =
           [](Pass *, Operation *) { return true; },
       bool printModuleScope = true, bool printAfterOnlyOnChange = true,
-      bool printAfterOnlyOnFailure = false,
-      bool printCustomFormOnFailure = false, raw_ostream &out = llvm::errs(),
+      bool printAfterOnlyOnFailure = false, raw_ostream &out = llvm::errs(),
       OpPrintingFlags opPrintingFlags = OpPrintingFlags());
 
   //===--------------------------------------------------------------------===//

diff  --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index 437a564732a1b..9e1e56ba4cb63 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -171,9 +171,7 @@ void IRPrinterInstrumentation::runAfterPassFailed(Pass *pass, Operation *op) {
   config->printAfterIfEnabled(pass, op, [&](raw_ostream &out) {
     out << formatv("// -----// IR Dump After {0} Failed", pass->getName());
     printIR(op, config->shouldPrintAtModuleScope(), out,
-            config->shouldPrintCustomFormOnFailure()
-                ? OpPrintingFlags()
-                : OpPrintingFlags().printGenericOpForm());
+            OpPrintingFlags().printGenericOpForm());
     out << "\n\n";
   });
 }
@@ -186,12 +184,10 @@ void IRPrinterInstrumentation::runAfterPassFailed(Pass *pass, Operation *op) {
 PassManager::IRPrinterConfig::IRPrinterConfig(bool printModuleScope,
                                               bool printAfterOnlyOnChange,
                                               bool printAfterOnlyOnFailure,
-                                              bool printCustomFormOnFailure,
                                               OpPrintingFlags opPrintingFlags)
     : printModuleScope(printModuleScope),
       printAfterOnlyOnChange(printAfterOnlyOnChange),
       printAfterOnlyOnFailure(printAfterOnlyOnFailure),
-      printCustomFormOnFailure(printCustomFormOnFailure),
       opPrintingFlags(opPrintingFlags) {}
 PassManager::IRPrinterConfig::~IRPrinterConfig() = default;
 
@@ -224,11 +220,10 @@ struct BasicIRPrinterConfig : public PassManager::IRPrinterConfig {
       std::function<bool(Pass *, Operation *)> shouldPrintBeforePass,
       std::function<bool(Pass *, Operation *)> shouldPrintAfterPass,
       bool printModuleScope, bool printAfterOnlyOnChange,
-      bool printAfterOnlyOnFailure, bool printCustomFormOnFailure,
-      OpPrintingFlags opPrintingFlags, raw_ostream &out)
+      bool printAfterOnlyOnFailure, OpPrintingFlags opPrintingFlags,
+      raw_ostream &out)
       : IRPrinterConfig(printModuleScope, printAfterOnlyOnChange,
-                        printAfterOnlyOnFailure, printCustomFormOnFailure,
-                        opPrintingFlags),
+                        printAfterOnlyOnFailure, opPrintingFlags),
         shouldPrintBeforePass(std::move(shouldPrintBeforePass)),
         shouldPrintAfterPass(std::move(shouldPrintAfterPass)), out(out) {
     assert((this->shouldPrintBeforePass || this->shouldPrintAfterPass) &&
@@ -272,10 +267,10 @@ void PassManager::enableIRPrinting(
     std::function<bool(Pass *, Operation *)> shouldPrintBeforePass,
     std::function<bool(Pass *, Operation *)> shouldPrintAfterPass,
     bool printModuleScope, bool printAfterOnlyOnChange,
-    bool printAfterOnlyOnFailure, bool printCustomFormOnFailure,
-    raw_ostream &out, OpPrintingFlags opPrintingFlags) {
+    bool printAfterOnlyOnFailure, raw_ostream &out,
+    OpPrintingFlags opPrintingFlags) {
   enableIRPrinting(std::make_unique<BasicIRPrinterConfig>(
       std::move(shouldPrintBeforePass), std::move(shouldPrintAfterPass),
       printModuleScope, printAfterOnlyOnChange, printAfterOnlyOnFailure,
-      printCustomFormOnFailure, opPrintingFlags, out));
+      opPrintingFlags, out));
 }

diff  --git a/mlir/lib/Pass/PassManagerOptions.cpp b/mlir/lib/Pass/PassManagerOptions.cpp
index 566fc3079b69e..7b725b2904b10 100644
--- a/mlir/lib/Pass/PassManagerOptions.cpp
+++ b/mlir/lib/Pass/PassManagerOptions.cpp
@@ -53,13 +53,6 @@ struct PassManagerOptions {
       llvm::cl::desc(
           "When printing the IR after a pass, only print if the pass failed"),
       llvm::cl::init(false)};
-  llvm::cl::opt<bool> printCustomAssemblyAfterFailure{
-      "mlir-print-custom-assembly-after-failure",
-      llvm::cl::desc(
-          "When printing the IR after a pass failure, print in custom form "
-          "instead of generic (WARNING: this is unsafe and there is no "
-          "guarantee of a crash-free or valid print"),
-      llvm::cl::init(false)};
   llvm::cl::opt<bool> printModuleScope{
       "mlir-print-ir-module-scope",
       llvm::cl::desc("When printing IR for print-ir-[before|after]{-all} "
@@ -129,7 +122,7 @@ void PassManagerOptions::addPrinterInstrumentation(PassManager &pm) {
   // Otherwise, add the IR printing instrumentation.
   pm.enableIRPrinting(shouldPrintBeforePass, shouldPrintAfterPass,
                       printModuleScope, printAfterChange, printAfterFailure,
-                      printCustomAssemblyAfterFailure, llvm::errs());
+                      llvm::errs());
 }
 
 void mlir::registerPassManagerCLOptions() {

diff  --git a/mlir/test/Pass/ir-printing.mlir b/mlir/test/Pass/ir-printing.mlir
index ac2b31f75d0d1..e60b0265f6228 100644
--- a/mlir/test/Pass/ir-printing.mlir
+++ b/mlir/test/Pass/ir-printing.mlir
@@ -5,7 +5,6 @@
 // RUN: mlir-opt %s -mlir-disable-threading=true -pass-pipeline='func.func(cse,canonicalize)' -mlir-print-ir-before=cse -mlir-print-ir-module-scope -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE_MODULE %s
 // RUN: mlir-opt %s -mlir-disable-threading=true -pass-pipeline='func.func(cse,cse)' -mlir-print-ir-after-all -mlir-print-ir-after-change -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER_ALL_CHANGE %s
 // RUN: not mlir-opt %s -mlir-disable-threading=true -pass-pipeline='func.func(cse,test-pass-failure)' -mlir-print-ir-after-failure -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER_FAILURE %s
-// RUN: not mlir-opt %s -mlir-disable-threading=true -pass-pipeline='func.func(cse,test-pass-failure)' -mlir-print-ir-after-failure -mlir-print-custom-assembly-after-failure -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER_FAILURE_CUSTOM %s
 
 func @foo() {
   %0 = arith.constant 0 : i32
@@ -65,5 +64,3 @@ func @bar() {
 
 // AFTER_FAILURE-NOT: // -----// IR Dump After{{.*}}CSE
 // AFTER_FAILURE: // -----// IR Dump After{{.*}}TestFailurePass Failed //----- //
-// AFTER_FAILURE_CUSTOM: // -----// IR Dump After{{.*}}TestFailurePass Failed //----- //
-// AFTER_FAILURE_CUSTOM: func @foo()


        


More information about the Mlir-commits mailing list