[PATCH] D142445: [mlir][tensor|memref] Harden the checks on dim op

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 08:18:12 PST 2023


mehdi_amini added a comment.

Here is some IR that passes the verifier, but crashes -canonicalize:

  func.func @dim(%arg : tensor<1x?xf32>) -> index {
    %c2 = arith.constant 2 : index
    %add = arith.addi %c2, %c2 : index
    %dim = tensor.dim %arg, %add : tensor<1x?xf32>
    return %dim : index
  }

The issue is that folding `arith.addi` is creating invalid IR: this is something that should never be possible, it breaks a strong invariant of the compiler.

The crash happens because the `tensor.dim` folder expects only valid IR (this is expected), but somehow we defined that `tensor.dim` with an out-of-bound constant access was invalid (hence my argument that this not a sound design for the verifier).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142445/new/

https://reviews.llvm.org/D142445



More information about the llvm-commits mailing list