[all-commits] [llvm/llvm-project] b4e461: [mlir] Return null from DenseElementsAttr::get on ...

Jueon Park via All-commits all-commits at lists.llvm.org
Thu Feb 12 08:32:19 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10
      https://github.com/llvm/llvm-project/commit/b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10
  Author: Jueon Park <79134656+JueonPark at users.noreply.github.com>
  Date:   2026-02-12 (Thu, 12 Feb 2026)

  Changed paths:
    M mlir/lib/IR/BuiltinAttributes.cpp
    M mlir/test/Dialect/Tensor/canonicalize.mlir

  Log Message:
  -----------
  [mlir] Return null from DenseElementsAttr::get on unsupported attribute types (#181159)

`DenseElementsAttr::get(ShapedType, ArrayRef<Attribute>)` crashed with an unconditional `cast<IntegerAttr>` when encountering attribute types that are neither `FloatAttr` nor `IntegerAttr` (e.g. `ub.poison`). This can happen when folding ops like `tensor.from_elements` whose operands include poison values.

This patch fixes the issue at the `DenseElementsAttr::get` level rather than in individual op folders. The `cast<IntegerAttr>` is replaced with `dyn_cast<IntegerAttr>`, and when the attribute is neither `FloatAttr` nor `IntegerAttr`, a null `DenseElementsAttr` is returned. This is a more robust fix because it prevents the same class of crashes in any caller that passes unsupported attributes to `DenseElementsAttr::get`.

Fixes #178209.

---------

Co-authored-by: rebel-jueonpark <jueonpark at rebellions.ai>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list