[Mlir-commits] [mlir] [mlir][bufferization] Fix promote-buffers-to-stack crash caused by nested memref (PR #127441)
Matthias Springer
llvmlistbot at llvm.org
Mon Feb 24 05:23:21 PST 2025
================
@@ -89,6 +89,11 @@ static bool defaultIsSmallAlloc(Value alloc, unsigned maximumSizeInBytes,
auto type = dyn_cast<ShapedType>(alloc.getType());
if (!type || !alloc.getDefiningOp<memref::AllocOp>())
return false;
+ auto elementType = type.getElementType();
+ // Not support nested memref type.
+ if (isa<MemRefType>(elementType))
----------------
matthias-springer wrote:
This will still crash on `UnrankedMemRefType` and certain types that implement `MemRefElementTypeInterface`. I think the right way to fix this is to add a helper function `DataLayout::hasKnownTypeSize(Type)`. Internally, there could be function that returns `std::optional<TypeSize>`, which is called by both `getTypeSizeInBits` and `hasKnownTypeSize`.
https://github.com/llvm/llvm-project/pull/127441
More information about the Mlir-commits
mailing list