[Mlir-commits] [mlir] [mlir] Rectify mishandling in `DenseElementsAttr::get(...)` causing crash with assertion when using `mlir-opt --canonicalize` (PR #88314)

Mehdi Amini llvmlistbot at llvm.org
Wed Apr 17 10:28:33 PDT 2024


joker-eph wrote:

It's not clear to me that the bug is in `DenseElementsAttr::get` actually, I would push the fix on the API call site instead.

However digging a bit more, the underlying problem seems that our folding hook tolerates that an attribute can be returned for an SSA Value with a type mismatch. This happens only for `llvm.constant in practice, because it accepts index types: `%1 = llvm.mlir.constant(1 : index) : i64`.
If we continue to accept this, then every folder should check that the attribute they get from matching a constant actually correspond to the expected SSA Type (in this case the fix would be in `InsertOpConstantFolder` for example).

https://github.com/llvm/llvm-project/pull/88314


More information about the Mlir-commits mailing list