[Mlir-commits] [mlir] [mlir][IR] Allow OpaqueAttr memory space. (PR #200151)
Karl Friebel
llvmlistbot at llvm.org
Thu May 28 03:15:34 PDT 2026
https://github.com/KFAFSP created https://github.com/llvm/llvm-project/pull/200151
This PR addresses issue #200150.
The verifier for `memref` accepts all attributes outside the builtin dialect, as well as a limited set of those within. This set does not contain the `OpaqueAttr`. Since, in generic form, MLIR attributes of unregistered dialects are stores as `OpaqueAttr`, this leads to unexpected results.
This commit adds `OpaqueAttr` to the list of allowed attributes, and adds a test.
>From 604c809f9d29b1d867fd1b87e746346d2cd1d29b Mon Sep 17 00:00:00 2001
From: "Karl F. A. Friebel" <karl.friebel at friebelnet.de>
Date: Thu, 28 May 2026 12:11:12 +0200
Subject: [PATCH] [mlir][IR] Allow OpaqueAttr memory space.
The verifier for `memref` accepts all attributes outside the builtin
dialect, as well as a limited set of those within. This set does not
contain the `OpaqueAttr`. Since, in generic form, MLIR attributes of
unregistered dialects are stores as `OpaqueAttr`, this leads to
unexpected results.
This commit adds `OpaqueAttr` to the list of allowed attributes, and
adds a test.
---
mlir/lib/IR/BuiltinTypes.cpp | 3 ++-
mlir/test/IR/parser.mlir | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index 786c30851a071..04e7926995d45 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -613,7 +613,8 @@ bool mlir::detail::isSupportedMemorySpace(Attribute memorySpace) {
return true;
// Supported built-in attributes.
- if (llvm::isa<IntegerAttr, StringAttr, DictionaryAttr>(memorySpace))
+ if (llvm::isa<IntegerAttr, StringAttr, DictionaryAttr, OpaqueAttr>(
+ memorySpace))
return true;
// Allow custom dialect attributes.
diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir
index e10dbf36e2797..ff95cca9b1f24 100644
--- a/mlir/test/IR/parser.mlir
+++ b/mlir/test/IR/parser.mlir
@@ -127,6 +127,12 @@ func.func private @memrefs_nomap_dictspace(memref<5x6x7xf32, {memSpace = "specia
// CHECK: func private @memrefs_map_dictspace(memref<5x6x7xf32, #map{{[0-9]*}}, {memSpace = "special", subIndex = 3 : i64}>)
func.func private @memrefs_map_dictspace(memref<5x6x7xf32, #map3, {memSpace = "special", subIndex = 3}>)
+// CHECK: func private @memrefs_nomap_opaquespace(memref<5x6x7xf32, #unregistered_dialect.attr<>>)
+func.func private @memrefs_nomap_opaquespace(memref<5x6x7xf32, #unregistered_dialect.attr<>>)
+
+// CHECK: func private @memrefs_map_opaquespace(memref<5x6x7xf32, #map{{[0-9]*}}, #unregistered_dialect.attr<>>)
+func.func private @memrefs_map_opaquespace(memref<5x6x7xf32, #map3, #unregistered_dialect.attr<>>)
+
// CHECK: func private @complex_types(complex<i1>) -> complex<f32>
func.func private @complex_types(complex<i1>) -> complex<f32>
More information about the Mlir-commits
mailing list