[all-commits] [llvm/llvm-project] 4bc235: [mlir][MemRef|Tensor] Fix the handling of DimOp

qcolombet via All-commits all-commits at lists.llvm.org
Thu Feb 16 02:54:29 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4bc2357c3de268b2b50ad0ff9c2c040329b75375
      https://github.com/llvm/llvm-project/commit/4bc2357c3de268b2b50ad0ff9c2c040329b75375
  Author: Quentin Colombet <quentin.colombet at gmail.com>
  Date:   2023-02-16 (Thu, 16 Feb 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
    M mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
    M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
    M mlir/test/Conversion/MemRefToLLVM/convert-static-memref-ops.mlir
    M mlir/test/Dialect/Tensor/invalid.mlir

  Log Message:
  -----------
  [mlir][MemRef|Tensor] Fix the handling of DimOp

Although specifying an index that is out of bounds for both `memref.dim`
and `tensor.dim` produces an undefined behavior, this is still valid IR.
In particular, we could expose an out of bound index because of some
optimizations, for instance as demonstrated with
https://github.com/llvm/llvm-project/issues/60295, and this shouldn't
cause the compiler to abort.

This patch removes the overzealous verifier checks and properly handles
out of bound indices (as in it doesn't crash the compiler, but still
produces UB).

This fixes https://github.com/llvm/llvm-project/issues/60295.

Note: That `shape.dim` has a similar problem but we're not supposed to
produce UB in this case. Instead we're supposed to propagate an error in
the resulting value and I don't know how to do that at the moment. Hence I
left this part out of the patch.

Differential Revision: https://reviews.llvm.org/D143999




More information about the All-commits mailing list