Mehdi Amini dd9dd1d2f3
[mlir][bufferization] Fix crash in promote-buffers-to-stack for nested memrefs (#186426)
The `--promote-buffers-to-stack` pass crashes when allocating a memref
whose element type is itself a memref (e.g., `memref<1xmemref<2xf32>>`).
This happens because `defaultIsSmallAlloc` calls
`DataLayout::getTypeSizeInBits` on the element type, but `MemRefType`
(and other types without `DataLayoutTypeInterface`) trigger a fatal
error when queried this way.

Fix the crash by checking whether the element type has data layout
support before computing its size. Types that are not int/float,
complex, index, or vector and do not implement `DataLayoutTypeInterface`
are silently skipped (i.e., the allocation is not promoted).

Fixes #60092

Assisted-by: Claude Code
2026-03-18 16:44:26 +01:00
..