[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
Loading
Please sign in to comment