[Mlir-commits] [mlir] 0ba4f13 - [mlir][test] Fix crash in ReifyBoundOp with invalid 'type' attribute (#184004)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Mar 1 05:15:09 PST 2026


Author: Mehdi Amini
Date: 2026-03-01T13:15:03Z
New Revision: 0ba4f13b264a385ffdcdcb77c935f6c503ba62df

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

LOG: [mlir][test] Fix crash in ReifyBoundOp with invalid 'type' attribute (#184004)

The `ReifyBoundOp::getBoundType()` called `llvm_unreachable("invalid
bound type")` when the `type` attribute was set to a value other than
"EQ", "LB", or "UB" (e.g., "scalable"). This caused an abort instead of
a user-visible diagnostic.

Add a verification check that rejects invalid `type` values with a
proper error message before `getBoundType()` is ever called.

Fixes #128805

Added: 
    

Modified: 
    mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir
    mlir/test/lib/Dialect/Test/TestOpDefs.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir b/mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir
index e923ac19c5177..e72457c776d69 100644
--- a/mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir
+++ b/mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir
@@ -44,4 +44,14 @@ func.func @test_invalid_reify_without_dim(%size: index) -> (index) {
     %dim = "test.reify_bound"(%tensor_val) : (tensor<?xf32>) -> index
 
     return %dim: index
+}
+
+// -----
+
+// Verify that an invalid 'type' value produces a proper error rather than
+// crashing with llvm_unreachable. See: https://github.com/llvm/llvm-project/issues/128805
+func.func @test_invalid_bound_type(%val: index) -> index {
+    // expected-error at +1 {{'test.reify_bound' op invalid bound type 'scalable', expected 'EQ', 'LB', or 'UB'}}
+    %bound = "test.reify_bound"(%val) {type = "scalable"} : (index) -> index
+    return %bound : index
 }
\ No newline at end of file

diff  --git a/mlir/test/lib/Dialect/Test/TestOpDefs.cpp b/mlir/test/lib/Dialect/Test/TestOpDefs.cpp
index d2826cc42b270..c243bd79a44a8 100644
--- a/mlir/test/lib/Dialect/Test/TestOpDefs.cpp
+++ b/mlir/test/lib/Dialect/Test/TestOpDefs.cpp
@@ -1014,6 +1014,9 @@ mlir::presburger::BoundType ReifyBoundOp::getBoundType() {
 }
 
 LogicalResult ReifyBoundOp::verify() {
+  if (getType() != "EQ" && getType() != "LB" && getType() != "UB")
+    return emitOpError("invalid bound type '")
+           << getType() << "', expected 'EQ', 'LB', or 'UB'";
   if (isa<ShapedType>(getVar().getType())) {
     if (!getDim().has_value())
       return emitOpError("expected 'dim' attribute for shaped type variable");


        


More information about the Mlir-commits mailing list