[PATCH] D143999: [mlir][MemRef|Tensor] Fix the handling of DimOp
Quentin Colombet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 03:37:10 PST 2023
qcolombet created this revision.
qcolombet added reviewers: mehdi_amini, ftynse, nicolasvasilache.
qcolombet added a project: MLIR.
Herald added subscribers: hanchung, Moerafaat, zero9178, bzcheeseman, awarzynski, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, thopre.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.
Herald added a reviewer: dcaballe.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143999
Files:
mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Conversion/MemRefToLLVM/convert-static-memref-ops.mlir
mlir/test/Dialect/Tensor/invalid.mlir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143999.497264.patch
Type: text/x-patch
Size: 7192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230214/c306b003/attachment.bin>
More information about the llvm-commits
mailing list