[Mlir-commits] [mlir] [MLIR][Bufferization] Fix IdentityLayoutMap allocation at function boundaries (PR #227253)

Aaditya Agarwal llvmlistbot at llvm.org
Wed Sep 30 01:52:31 PDT 2026


aaditya8979 wrote:

@matthias-springer  Good question. castOrReallocMemRefValue is the general-purpose utility — it handles cases like ranked-to-unranked casts and dynamic-to-static shape changes. The bug in this issue is specifically at func.call operand boundaries where the target type is identity-layout (from IdentityLayoutMap) but the source has a non-zero offset or stride. In that scenario, castOrReallocMemRefValue falls through to memref.cast, which is valid for layout-compatible casts but not when the source carries a non-zero offset that needs to be zeroed. The callee receives a contiguous-looking type but loads from offset 0 of the non-zero-offset source buffer.

This patch specifically guards the CallOp boundary. If castOrReallocMemRefValue is also triggered via to_buffer/to_tensor() canonicalization paths with the same layout mismatch, that would be a separate, independent bug worth a separate issue and patch.

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


More information about the Mlir-commits mailing list