Skip to content

Commit 53b6353

Browse files
committed
use original error message (as per review comment)
1 parent edcefce commit 53b6353

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,12 +3303,15 @@ LogicalResult LLVM::ConstantOp::verify() {
33033303
<< elementTypes.size();
33043304
}
33053305
for (auto [i, attr, type] : llvm::enumerate(arrayAttr, elementTypes)) {
3306-
if (!isa<IntegerAttr, FloatAttr>(attr)) {
3306+
if (!type.isSignlessIntOrIndexOrFloat()) {
3307+
return emitOpError() << "expected struct element types to be floating "
3308+
"point type or integer type";
3309+
}
3310+
if (!isa<FloatAttr, IntegerAttr>(attr)) {
33073311
return emitOpError() << "expected element of array attribute to be "
33083312
"floating point or integer";
33093313
}
3310-
auto attrType = cast<TypedAttr>(attr).getType();
3311-
if (attrType != type)
3314+
if (cast<TypedAttr>(attr).getType() != type)
33123315
return emitOpError()
33133316
<< "struct element at index " << i << " is of wrong type";
33143317
}

mlir/test/Dialect/LLVMIR/invalid.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ llvm.func @struct_two_different_elements() -> !llvm.struct<(f64, f32)> {
418418
// -----
419419

420420
llvm.func @struct_wrong_element_types() -> !llvm.struct<(!llvm.array<2 x f64>, !llvm.array<2 x f64>)> {
421-
// expected-error @+1 {{expected element of array attribute to be floating point or integer}}
421+
// expected-error @+1 {{expected struct element types to be floating point type or integer type}}
422422
%0 = llvm.mlir.constant([dense<[1.0, 1.0]> : tensor<2xf64>, dense<[1.0, 1.0]> : tensor<2xf64>]) : !llvm.struct<(!llvm.array<2 x f64>, !llvm.array<2 x f64>)>
423423
llvm.return %0 : !llvm.struct<(!llvm.array<2 x f64>, !llvm.array<2 x f64>)>
424424
}
@@ -523,7 +523,7 @@ llvm.func @elements_attribute_incompatible_nested_array_struct3_type() -> !llvm.
523523
// -----
524524

525525
llvm.func @invalid_struct_element_type() -> !llvm.struct<(f64, array<2 x i32>)> {
526-
// expected-error @below{{expected element of array attribute to be floating point or integer}}
526+
// expected-error @below{{expected struct element types to be floating point type or integer type}}
527527
%0 = llvm.mlir.constant([1.0 : f64, dense<[1, 2]> : tensor<2xi32>]) : !llvm.struct<(f64, array<2 x i32>)>
528528
llvm.return %0 : !llvm.struct<(f64, array<2 x i32>)>
529529
}

0 commit comments

Comments
 (0)