[all-commits] [llvm/llvm-project] 1949fe: [mlir] Verify non-negative `offset` and `size` (#7...

Rik Huijzer via All-commits all-commits at lists.llvm.org
Wed Nov 15 22:42:57 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1949fe90bfccaa13b4ecbce33de3123824b9a150
      https://github.com/llvm/llvm-project/commit/1949fe90bfccaa13b4ecbce33de3123824b9a150
  Author: Rik Huijzer <github at huijzer.xyz>
  Date:   2023-11-16 (Thu, 16 Nov 2023)

  Changed paths:
    M mlir/include/mlir/Interfaces/ViewLikeInterface.td
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
    M mlir/lib/Interfaces/ViewLikeInterface.cpp
    M mlir/test/Dialect/MemRef/canonicalize.mlir
    M mlir/test/Dialect/MemRef/invalid.mlir

  Log Message:
  -----------
  [mlir] Verify non-negative `offset` and `size` (#72059)

In #71153, the `memref.subview` canonicalizer crashes due to a negative
`size` being passed as an operand. During `SubViewOp::verify` this
negative `size` is not yet detectable since it is dynamic and only
available after constant folding, which happens during the
canonicalization passes. As discussed in
<https://discourse.llvm.org/t/rfc-more-opfoldresult-and-mixed-indices-in-ops-that-deal-with-shaped-values/72510>,
the verifier should not be extended as it should "only verify local
aspects of an operation".

This patch fixes #71153 by not folding in aforementioned situation.

Also, this patch adds a basic offset and size check in the
`OffsetSizeAndStrideOpInterface` verifier.

Note: only `offset` and `size` are checked because `stride` is allowed
to be negative
(https://github.com/llvm/llvm-project/commit/54d81e49e3b72f6a305891fe169ecd7c6f559223).




More information about the All-commits mailing list