[Mlir-commits] [mlir] 4ec3afc - [mlir] Accept OpaqueAttr as a valid memory space if the context allows unregistered dialects (#187682)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Sep 11 06:53:07 PDT 2026


Author: Adam Paszke
Date: 2026-09-11T15:53:02+02:00
New Revision: 4ec3afcec324456abdda0e75a3cfbbbcabff9714

URL: https://github.com/llvm/llvm-project/commit/4ec3afcec324456abdda0e75a3cfbbbcabff9714
DIFF: https://github.com/llvm/llvm-project/commit/4ec3afcec324456abdda0e75a3cfbbbcabff9714.diff

LOG: [mlir] Accept OpaqueAttr as a valid memory space if the context allows unregistered dialects (#187682)

When a context allows unregistered dialects and an unknown attribute is
encountered, it is wrapped in OpaqueAttr from the builtin dialect.

Added: 
    

Modified: 
    mlir/lib/IR/BuiltinTypes.cpp
    mlir/test/IR/parser.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index 1c3021940ef02..1608b245686e2 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -617,6 +617,12 @@ bool mlir::detail::isSupportedMemorySpace(Attribute memorySpace) {
   if (llvm::isa<IntegerAttr, StringAttr, DictionaryAttr>(memorySpace))
     return true;
 
+  // Allow opaque attributes if unregistered dialects are allowed.
+  // They hold unregistered custom dialect attributes.
+  if (memorySpace.getContext()->allowsUnregisteredDialects() &&
+      isa<OpaqueAttr>(memorySpace))
+    return true;
+
   // Allow custom dialect attributes.
   if (!isa<BuiltinDialect>(memorySpace.getDialect()))
     return true;

diff  --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir
index 536f6794c9298..6cd07f616540f 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, #unknown_dialect.unknown_attr>)
+func.func private @memrefs_nomap_opaquespace(memref<5x6x7xf32, #unknown_dialect.unknown_attr>)
+
+// CHECK: func private @memrefs_map_opaquespace(memref<5x6x7xf32, #map{{[0-9]*}}, #unknown_dialect.unknown_attr>)
+func.func private @memrefs_map_opaquespace(memref<5x6x7xf32, #map3, #unknown_dialect.unknown_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