[Mlir-commits] [mlir] cab7d1e - [mlir][reducer] Repalce module.emitWarning with module.emitError in ReductionTree pass (#190584)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 6 22:56:53 PDT 2026
Author: lonely eagle
Date: 2026-04-07T13:56:48+08:00
New Revision: cab7d1e485ca02074c7499020b289c726b06d5cf
URL: https://github.com/llvm/llvm-project/commit/cab7d1e485ca02074c7499020b289c726b06d5cf
DIFF: https://github.com/llvm/llvm-project/commit/cab7d1e485ca02074c7499020b289c726b06d5cf.diff
LOG: [mlir][reducer] Repalce module.emitWarning with module.emitError in ReductionTree pass (#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.
Added:
mlir/test/mlir-reduce/false.sh
mlir/test/mlir-reduce/true.sh
Modified:
mlir/lib/Reducer/ReductionTreePass.cpp
mlir/test/mlir-reduce/invalid.mlir
mlir/test/mlir-reduce/simple-test.mlir
Removed:
mlir/test/mlir-reduce/test.sh
################################################################################
diff --git a/mlir/lib/Reducer/ReductionTreePass.cpp b/mlir/lib/Reducer/ReductionTreePass.cpp
index 83497143d9669..13cad4e7e9d47 100644
--- a/mlir/lib/Reducer/ReductionTreePass.cpp
+++ b/mlir/lib/Reducer/ReductionTreePass.cpp
@@ -89,7 +89,7 @@ static LogicalResult findOptimal(ModuleOp module, Region ®ion,
// 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;
@@ -155,7 +155,7 @@ static LogicalResult eraseAllOpsInRegion(ModuleOp module, Region ®ion,
// 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
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