[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
This commit is contained in:
Mehdi Amini 2026-03-01 14:15:03 +01:00 committed by GitHub
parent 785490e9db
commit 0ba4f13b26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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@+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
}

View File

@ -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");