[Mlir-commits] [mlir] [mlir][memref] Verify out-of-bounds access for `memref.subview` (PR #131876)
Matthias Springer
llvmlistbot at llvm.org
Tue Mar 25 02:54:32 PDT 2025
================
@@ -3025,6 +3028,14 @@ LogicalResult SubViewOp::verify() {
return produceSubViewErrorMsg(SliceVerificationResult::LayoutMismatch,
*this, expectedType);
+ // Verify that offsets, sizes, strides do not run out-of-bounds with respect
+ // to the base memref.
+ SliceBoundsVerificationResult boundsResult =
+ verifyInBoundsSlice(baseType.getShape(), staticOffsets, staticSizes,
+ staticStrides, /*generateErrorMessage=*/true);
+ if (!boundsResult.isValid)
+ return getOperation()->emitError(boundsResult.errorMessage);
----------------
matthias-springer wrote:
I tried to reuse `produceSubViewErrorMsg` in an earlier version. For that, I have to add another item to the `SliceVerificationResult` enum. `SliceVerificationResult` is currently defined in `BuiltinTypes.h`. I didn't want to include offset-sizes-strides-related behavior in that file because all of that logic is currently in `ViewLikeInterface.h`. So this is mostly a layering issue.
https://github.com/llvm/llvm-project/pull/131876
More information about the Mlir-commits
mailing list