[Mlir-commits] [mlir] [mlir][sparse] Do not access operation after it was replaced (PR #146546)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jul 1 08:25:18 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-sparse

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

Accessing an erased operation will no longer work during a One-Shot Dialect Conversion.

---
Full diff: https://github.com/llvm/llvm-project/pull/146546.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp (+1-1) 


``````````diff
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
index 7f0b657687442..65adc37808fe4 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
@@ -729,9 +729,9 @@ class SparseTensorCompressConverter : public OpConversionPattern<CompressOp> {
     createFuncCall(rewriter, loc, name, {},
                    {tensor, lvlCoords, values, filled, added, count},
                    EmitCInterface::On);
+    Operation *parent = getTop(op);
     rewriter.replaceOp(op, adaptor.getTensor());
     // Deallocate the buffers on exit of the loop nest.
-    Operation *parent = getTop(op);
     rewriter.setInsertionPointAfter(parent);
     rewriter.create<memref::DeallocOp>(loc, values);
     rewriter.create<memref::DeallocOp>(loc, filled);

``````````

</details>


https://github.com/llvm/llvm-project/pull/146546


More information about the Mlir-commits mailing list