[Mlir-commits] [mlir] [mlir][IR] Allow OpaqueAttr memory space. (PR #200151)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 28 03:16:18 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Karl Friebel (KFAFSP)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/200151.diff


2 Files Affected:

- (modified) mlir/lib/IR/BuiltinTypes.cpp (+2-1) 
- (modified) mlir/test/IR/parser.mlir (+6) 


``````````diff
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>
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/200151


More information about the Mlir-commits mailing list