[Mlir-commits] [mlir] [MLIR][MemRef] Validate linear size before lowering allocs (PR #179155)
Matthias Springer
llvmlistbot at llvm.org
Sun Feb 1 23:49:26 PST 2026
================
@@ -164,8 +164,11 @@ class AllocOpLowering : public ConvertOpToLLVMPattern<memref::AllocOp> {
SmallVector<Value, 4> strides;
Value sizeBytes;
- this->getMemRefDescriptorSizes(loc, memRefType, adaptor.getOperands(),
- rewriter, sizes, strides, sizeBytes, true);
+ if (failed(this->getMemRefDescriptorSizes(loc, memRefType,
+ adaptor.getOperands(), rewriter,
+ sizes, strides, sizeBytes, true)))
+ return rewriter.notifyMatchFailure(
----------------
matthias-springer wrote:
Here and in the other patterns: `matchAndRewrite` must not return "failure" when the IR has already been modified. This "if" check must be before `getNotalignedAllocFn`.
However, `getNotalignedAllocFn` can also fail, so it must be before `getMemRefDescriptorSizes`.
The size check must be in a separate function that returns `LogicalResult`. `getMemRefDescriptorSizes` should keep returning `void`.
https://github.com/llvm/llvm-project/pull/179155
More information about the Mlir-commits
mailing list