[mlir][LLVM] Support opaque pointers in data layout entries

This is likely preferable to having it crash if one were to specify an opaque pointer type, and the actual element type is unused either way.

Differential Revision: https://reviews.llvm.org/D124334
This commit is contained in:
Markus Böck 2022-04-25 09:14:18 +02:00
parent e33867a434
commit 34312f1f0c
2 changed files with 8 additions and 2 deletions

View File

@ -340,7 +340,7 @@ LogicalResult LLVMPointerType::verifyEntries(DataLayoutEntryListRef entries,
<< " to be a dense integer elements attribute with 3 or 4 "
"elements";
}
if (!key.getElementType().isInteger(8)) {
if (key.getElementType() && !key.getElementType().isInteger(8)) {
return emitError(loc) << "unexpected layout attribute for pointer to "
<< key.getElementType();
}

View File

@ -46,7 +46,8 @@ module {
module attributes { dlti.dl_spec = #dlti.dl_spec<
#dlti.dl_entry<!llvm.ptr<i8>, dense<[32, 32, 64]> : vector<3xi32>>,
#dlti.dl_entry<!llvm.ptr<i8, 5>, dense<[64, 64, 64]> : vector<3xi32>>
#dlti.dl_entry<!llvm.ptr<i8, 5>, dense<[64, 64, 64]> : vector<3xi32>>,
#dlti.dl_entry<!llvm.ptr<4>, dense<[32, 64, 64]> : vector<3xi32>>
>} {
// CHECK: @spec
func.func @spec() {
@ -85,6 +86,11 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
// CHECK: preferred = 8
// CHECK: size = 4
"test.data_layout_query"() : () -> !llvm.ptr<3>
// CHECK: alignment = 8
// CHECK: bitsize = 32
// CHECK: preferred = 8
// CHECK: size = 4
"test.data_layout_query"() : () -> !llvm.ptr<4>
return
}
}