[Mlir-commits] [mlir] [mlir][tensor] Fix crash in FromElementsOp::fold with poison values (PR #179113)
Jueon Park
llvmlistbot at llvm.org
Thu Feb 12 07:00:07 PST 2026
JueonPark wrote:
> Thanks for fixing this. There is another way to fix this bug, which would potentially also fix similar bugs in other places.
>
> ```
> --- a/mlir/lib/IR/BuiltinAttributes.cpp
> +++ b/mlir/lib/IR/BuiltinAttributes.cpp
> @@ -972,11 +972,13 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type,
> assert(floatAttr.getType() == eltType &&
> "expected float attribute type to equal element type");
> intVal = floatAttr.getValue().bitcastToAPInt();
> - } else {
> - auto intAttr = llvm::cast<IntegerAttr>(values[i]);
> + } else if (auto intAttr = llvm::dyn_cast<IntegerAttr>(values[i])) {
> assert(intAttr.getType() == eltType &&
> "expected integer attribute type to equal element type");
> intVal = intAttr.getValue();
> + } else {
> + // Unsupported attribute type.
> + return {};
> }
> ```
>
> But I'm not sure if you can return a "null" attribute from an attribute getter? @joker-eph @ftynse
@matthias-springer Sorry for the delay. I made an alternative [PR](https://github.com/llvm/llvm-project/pull/181159) based on your feedback :)
https://github.com/llvm/llvm-project/pull/179113
More information about the Mlir-commits
mailing list