Skip to content

Commit 0b9a69b

Browse files
[mlir][Transforms] Dialect conversion: Fix bug in UnresolvedMaterializationRewrite rollback
When an unresolved materializations (`unrealized_conversion_cast` op) is rolled back, the mapping should be rolled back as well, regardless of whether it is a source, target or argument materialization. Otherwise, we accumulate pointers to erased IR in the `mapping`. This is harmless in most cases, but can cause issues when a new operation is allocated at the same memory location and the pointer is "reused". It is not possible to write a test case for this because I cannot trigger the pointer reuse programmatically.
1 parent d7073c5 commit 0b9a69b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,8 @@ void CreateOperationRewrite::rollback() {
10621062
}
10631063

10641064
void UnresolvedMaterializationRewrite::rollback() {
1065-
if (getMaterializationKind() == MaterializationKind::Target) {
1066-
for (Value input : op->getOperands())
1067-
rewriterImpl.mapping.erase(input);
1068-
}
1065+
for (Value input : op->getOperands())
1066+
rewriterImpl.mapping.erase(input);
10691067
op->erase();
10701068
}
10711069

0 commit comments

Comments
 (0)