[Mlir-commits] [mlir] [mlir][tensor] Fix crash in FromElementsOp::fold with poison values (PR #179113)
Matthias Springer
llvmlistbot at llvm.org
Sun Feb 1 07:37:21 PST 2026
https://github.com/matthias-springer commented:
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
https://github.com/llvm/llvm-project/pull/179113
More information about the Mlir-commits
mailing list