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

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 10:19:32 PST 2023


mehdi_amini added a comment.

In D142445#4077807 <https://reviews.llvm.org/D142445#4077807>, @qcolombet wrote:

>> I'm always a bit worried when we turn something from "UB" into "invalid IR": the issue being "action at distance". That is, are there patterns, fold, etc. that reduce the rank of a memref and build invalid IR unexpectedly?
>
> I can see that, but at the same time, if that happens the generated code would be silently broken.

That is the concept of UB though :)

> If there were practical reasons to support that, I could  live with it but I don't know if it is a pattern that happens in practice.
> Anyhow, to be more concrete here, do you think we should support (as in don't crash the compiler) dim op of 0-D shapes?

We should not crash the compiler, we can generate ud2 / llvm.unreachable or anything instead :)

> This patch basically changes a crash on clearly UB IR (I guess we could come up with a semantic for dim of 0-D though) to the compiler emitting an error.

Yes but you can't prove this path will be executed at runtime...


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