-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Rectify mishandling in InsertOpConstantFolder
causing crash with assertion when using mlir-opt --canonicalize
#88314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir-core Author: Rajveer Singh Bharadwaj (Rajveer100) ChangesResolves #74236 In Full diff: https://github.com/llvm/llvm-project/pull/88314.diff 2 Files Affected:
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
+}
|
@joker-eph Let me know the direction for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch and repro. There is something subtle going on here that I can't just spot in a code review. If others can't either, it will need someone familiar to step through it and fix properly vs just giving advice. In that case, probably needs an issue vs PR so we don't lose it.
It's not clear to me that the bug is in 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 |
44ea5e1
to
8e44901
Compare
DenseElementsAttr::get(...)
causing crash with assertion when using mlir-opt --canonicalize
InsertOpConstantFolder
causing crash with assertion when using mlir-opt --canonicalize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG with a few comments
…with assertion when using `mlir-opt --canonicalize` Resolves llvm#74236
8e44901
to
1bf4fbe
Compare
Resolves #74236