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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 6 00:37:17 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: lonely eagle (linuxlonelyeagle)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/190584.diff


5 Files Affected:

- (modified) mlir/lib/Reducer/ReductionTreePass.cpp (+3-3) 
- (added) mlir/test/mlir-reduce/false.sh (+6) 
- (modified) mlir/test/mlir-reduce/invalid.mlir (+4-1) 
- (modified) mlir/test/mlir-reduce/simple-test.mlir (+1-1) 
- (renamed) mlir/test/mlir-reduce/true.sh () 


``````````diff
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

``````````

</details>


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


More information about the Mlir-commits mailing list