From: Alex Zinenko Date: Wed, 9 Jun 2021 09:51:04 +0000 (+0200) Subject: [mlir] fix a crash if the dialect is missing a data layout interface X-Git-Tag: llvmorg-14-init~4429 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6faa71eafbcd52d5154aadf888fce8b3af73c16;p=platform%2Fupstream%2Fllvm.git [mlir] fix a crash if the dialect is missing a data layout interface The top-level verifier of data layout specifications delegates verification of entries with identifier keys to the dialect of the identifier prefix. This flow was missing a check whether the dialect actually implements the relevant interface. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D103945 --- diff --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp index 1f219c1..f32acd5 100644 --- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp +++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp @@ -440,6 +440,11 @@ LogicalResult mlir::detail::verifyDataLayoutSpec(DataLayoutSpecInterface spec, const auto *iface = dialect->getRegisteredInterface(); + if (!iface) { + return emitError(loc) + << "the '" << dialect->getNamespace() + << "' dialect does not support identifier data layout entries"; + } if (failed(iface->verifyEntry(kvp.second, loc))) return failure(); } diff --git a/mlir/test/Interfaces/DataLayoutInterfaces/types.mlir b/mlir/test/Interfaces/DataLayoutInterfaces/types.mlir index 02adc7f..8c1fe50 100644 --- a/mlir/test/Interfaces/DataLayoutInterfaces/types.mlir +++ b/mlir/test/Interfaces/DataLayoutInterfaces/types.mlir @@ -7,6 +7,13 @@ module attributes { dlti.dl_spec = #dlti.dl_spec< // ----- +// expected-error@below {{the 'test' dialect does not support identifier data layout entries}} +"test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec< + #dlti.dl_entry, + #dlti.dl_entry<"test.foo", [32]>>} : () -> () + +// ----- + // CHECK-LABEL: @index module @index attributes { dlti.dl_spec = #dlti.dl_spec< #dlti.dl_entry>} {