[Mlir-commits] [mlir] [mlir] Rectify mishandling in `DenseElementsAttr::get(...)` causing crash with assertion when using `mlir-opt --canonicalize` (PR #88314)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 10 12:24:24 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Rajveer Singh Bharadwaj (Rajveer100)
<details>
<summary>Changes</summary>
Resolves #<!-- -->74236
In `BuiltinAttributes` when we recursively handle complex types and simplify them into integer, float, string, etc., index type needs to be handled for vector-based operations before making an assertion.
---
Full diff: https://github.com/llvm/llvm-project/pull/88314.diff
2 Files Affected:
- (modified) mlir/lib/IR/BuiltinAttributes.cpp (+2)
- (added) mlir/test/mlir-opt/issue-74236.mlir (+10)
``````````diff
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index 89b1ed67f5d067..adca7af7a91336 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -958,6 +958,8 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type,
intVal = floatAttr.getValue().bitcastToAPInt();
} else {
auto intAttr = llvm::cast<IntegerAttr>(values[i]);
+ if (intAttr.getType().isIndex())
+ continue;
assert(intAttr.getType() == eltType &&
"expected integer attribute type to equal element type");
intVal = intAttr.getValue();
diff --git a/mlir/test/mlir-opt/issue-74236.mlir b/mlir/test/mlir-opt/issue-74236.mlir
new file mode 100644
index 00000000000000..559daead0cf9c7
--- /dev/null
+++ b/mlir/test/mlir-opt/issue-74236.mlir
@@ -0,0 +1,10 @@
+// RUN: mlir-opt -split-input-file -verify-diagnostics %s
+
+llvm.func @malloc(i64) -> !llvm.ptr
+func.func @func2(%arg0: index, %arg1: memref<13x13xi64>, %arg2: index) {
+ %cst_7 = arith.constant dense<1526248407> : vector<1xi64>
+ %1 = llvm.mlir.constant(1 : index) : i64
+ %101 = vector.insert %1, %cst_7 [0] : i64 into vector<1xi64>
+ vector.print %101 : vector<1xi64>
+ return
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/88314
More information about the Mlir-commits
mailing list