diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp @@ -702,9 +702,12 @@ Type LLVMStructType::replaceImmediateSubElements( ArrayRef replAttrs, ArrayRef replTypes) const { - // TODO: It's not clear how we support replacing sub-elements of mutable - // types. - return nullptr; + if (isIdentified()) { + // TODO: It's not clear how we support replacing sub-elements of mutable + // types. + return nullptr; + } + return getLiteral(getContext(), replTypes, isPacked()); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/SubElementInterfaces.cpp b/mlir/lib/IR/SubElementInterfaces.cpp --- a/mlir/lib/IR/SubElementInterfaces.cpp +++ b/mlir/lib/IR/SubElementInterfaces.cpp @@ -93,14 +93,6 @@ //===----------------------------------------------------------------------===// // ReplaceSubElements -/// Return if the given element is mutable. -static bool isMutable(Attribute attr) { - return attr.hasTrait(); -} -static bool isMutable(Type type) { - return type.hasTrait(); -} - template static void updateSubElementImpl( T element, function_ref(T)> walkFn, @@ -187,12 +179,6 @@ if (!*changed) return interface; - // If this element is mutable, we don't support changing its sub elements, the - // sub element walk doesn't give us a valid ordering for what we need here. If - // we want to support mutable elements, we'll need something more. - if (isMutable(interface)) - return {}; - // Use the new elements during the replacement. return interface.replaceImmediateSubElements(newAttrs, newTypes); }