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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Mar 20 04:43:16 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Adam Paszke (apaszke)

<details>
<summary>Changes</summary>



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

This used to work fine, but recently, MLIR bitcode deserialization started verifying the MemRef types it creates. This causes deserailization errors unless OpaqueAttr is considered a valid memref memory space.

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


1 Files Affected:

- (modified) mlir/lib/IR/BuiltinTypes.cpp (+6) 


``````````diff
diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index 786c30851a071..0bebbe7aea33a 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -616,6 +616,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;

``````````

</details>


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


More information about the Mlir-commits mailing list