[Mlir-commits] [mlir] [mlir] Fix integer overflow in ShapedType::getNumElements and `makeCanonicalStridedLayoutExpr` (PR #178395)

Matthias Springer llvmlistbot at llvm.org
Fri Jan 30 06:12:34 PST 2026


matthias-springer wrote:

I'm wondering if this PR was the correct. Pretty much the entire MLIR code base assumes that the number of elements fits into `int64_t`. With this PR, you can round-trip it successfully, but most transformations still won't work correctly.

IMO there are two ways to fix the issues referenced in this PR:
1. Do what this PR did. That means that we are committing to fixing the remaining MLIR code base eventually, so that they support such large sizes. Given that the referenced issues seem to be fuzzer-generated, is this something that we would like to sign up for as a community?
2. Reject IR where the number of elements does not fit into `int64_t` in the verifier + parser.

Any thoughts?

Coming back to the new UBSAN failure: `getMemRefDescriptorSizes` requires that the number of bytes of the memref fits into `int64_t`. I don't see an easy way to fix that. The `IndexType` does not support values larger than 64-bit (?). So we have to update all call sites (patterns) of `getMemRefDescriptorSizes` and `return failure()`. (Doing this check in `getMemRefDescriptorSizes` itself is too late, because the pattern where this is called may already have created new IR.)


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


More information about the Mlir-commits mailing list