[Mlir-commits] [mlir] [mlir][reducer] Repalce module.emitWarning with module.emitError in ReductionTree pass (PR #190584)

lonely eagle llvmlistbot at llvm.org
Mon Apr 6 00:36:44 PDT 2026


https://github.com/linuxlonelyeagle created https://github.com/llvm/llvm-project/pull/190584

This PR fixes the diagnostic message for mlir-reduce's reduction-tree  pass when the input module is not "interesting". Previously, running with the warning pass would fail silently, and enabling debug options would only show a generic "pass manager run failed" message without any useful diagnostic information.

>From fa064e49921284f9f5ae4e81b356685968d328a8 Mon Sep 17 00:00:00 2001
From: linuxlonelyeagle <2020382038 at qq.com>
Date: Mon, 6 Apr 2026 07:29:15 +0000
Subject: [PATCH] repalce module.emitwarning with module.emiterror.

---
 mlir/lib/Reducer/ReductionTreePass.cpp     | 6 +++---
 mlir/test/mlir-reduce/false.sh             | 6 ++++++
 mlir/test/mlir-reduce/invalid.mlir         | 5 ++++-
 mlir/test/mlir-reduce/simple-test.mlir     | 2 +-
 mlir/test/mlir-reduce/{test.sh => true.sh} | 0
 5 files changed, 14 insertions(+), 5 deletions(-)
 create mode 100755 mlir/test/mlir-reduce/false.sh
 rename mlir/test/mlir-reduce/{test.sh => true.sh} (100%)

diff --git a/mlir/lib/Reducer/ReductionTreePass.cpp b/mlir/lib/Reducer/ReductionTreePass.cpp
index 12358f7d71688..af39faa4d9e32 100644
--- a/mlir/lib/Reducer/ReductionTreePass.cpp
+++ b/mlir/lib/Reducer/ReductionTreePass.cpp
@@ -95,7 +95,7 @@ static LogicalResult findOptimal(ModuleOp module, Region &region,
   // While exploring the reduction tree, we always branch from an interesting
   // node. Thus the root node must be interesting.
   if (initStatus.first != Tester::Interestingness::True)
-    return module.emitWarning() << "uninterested module will not be reduced";
+    return module.emitError() << "uninterested module will not be reduced";
 
   llvm::SpecificBumpPtrAllocator<ReductionNode> allocator;
 
@@ -161,7 +161,7 @@ static LogicalResult eraseAllOpsInRegion(ModuleOp module, Region &region,
   // While exploring the reduction tree, we always branch from an interesting
   // node. Thus the root node must be interesting.
   if (initStatus.first != Tester::Interestingness::True)
-    return module.emitWarning() << "uninterested module will not be reduced";
+    return module.emitError() << "uninterested module will not be reduced";
   llvm::SpecificBumpPtrAllocator<ReductionNode> allocator;
 
   // Setting the ranges to {{0, 0}} will result in the deletion of all ops
@@ -213,7 +213,7 @@ static LogicalResult eraseRedundantBlocksInRegion(ModuleOp module,
   // While exploring the reduction tree, we always branch from an interesting
   // node. Thus the root node must be interesting.
   if (initStatus.first != Tester::Interestingness::True)
-    return module.emitWarning() << "uninterested module will not be reduced";
+    return module.emitError() << "uninterested module will not be reduced";
   llvm::SpecificBumpPtrAllocator<ReductionNode> allocator;
 
   // We set the simplification level to Aggressive to enable block merging.
diff --git a/mlir/test/mlir-reduce/false.sh b/mlir/test/mlir-reduce/false.sh
new file mode 100755
index 0000000000000..94d855ab1e58f
--- /dev/null
+++ b/mlir/test/mlir-reduce/false.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+#Replicate bug
+
+#Not interesting behavior
+exit 0
diff --git a/mlir/test/mlir-reduce/invalid.mlir b/mlir/test/mlir-reduce/invalid.mlir
index c421e20778311..43bcb68a32112 100644
--- a/mlir/test/mlir-reduce/invalid.mlir
+++ b/mlir/test/mlir-reduce/invalid.mlir
@@ -1,6 +1,9 @@
 // UNSUPPORTED: system-windows
 // RUN: not mlir-reduce -reduction-tree --no-implicit-module %s 2>&1 | FileCheck %s --check-prefix=CHECK-TREE
+// RUN: not mlir-reduce -reduction-tree='traversal-mode=0 test=%S/false.sh' %s 2>&1 | FileCheck %s --check-prefix=CHECK-INTERESTING
 
 // The reduction passes are currently restricted to 'builtin.module'.
-// CHECK-TREE: error: top-level op must be 'builtin.module'
+//        CHECK-TREE: error: top-level op must be 'builtin.module'
+
+// CHECK-INTERESTING: error: uninterested module will not be reduced
 func.func private @foo()
diff --git a/mlir/test/mlir-reduce/simple-test.mlir b/mlir/test/mlir-reduce/simple-test.mlir
index b50c39590bb92..7d189db6a206a 100644
--- a/mlir/test/mlir-reduce/simple-test.mlir
+++ b/mlir/test/mlir-reduce/simple-test.mlir
@@ -1,5 +1,5 @@
 // UNSUPPORTED: system-windows
-// RUN: mlir-reduce %s -reduction-tree='traversal-mode=0 test=%S/test.sh' | FileCheck %s
+// RUN: mlir-reduce %s -reduction-tree='traversal-mode=0 test=%S/true.sh' | FileCheck %s
 
 // Since the test.sh always returns 1 (interesting), 
 // all operations within the ModuleOp should be erased.
diff --git a/mlir/test/mlir-reduce/test.sh b/mlir/test/mlir-reduce/true.sh
similarity index 100%
rename from mlir/test/mlir-reduce/test.sh
rename to mlir/test/mlir-reduce/true.sh



More information about the Mlir-commits mailing list