[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: Fix bug in `UnresolvedMaterializationRewrite` rollback (PR #105949)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Aug 24 09:40:17 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
When an unresolved materialization (`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.
---
Full diff: https://github.com/llvm/llvm-project/pull/105949.diff
1 Files Affected:
- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+2-4)
``````````diff
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 4058ed39621198..11e40b74b00424 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -1062,10 +1062,8 @@ void CreateOperationRewrite::rollback() {
}
void UnresolvedMaterializationRewrite::rollback() {
- if (getMaterializationKind() == MaterializationKind::Target) {
- for (Value input : op->getOperands())
- rewriterImpl.mapping.erase(input);
- }
+ for (Value input : op->getOperands())
+ rewriterImpl.mapping.erase(input);
op->erase();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/105949
More information about the Mlir-commits
mailing list