[Mlir-commits] [mlir] dbbd907 - [mlir][TilingInterface] Fix use after free error from D141028.
Mahesh Ravishankar
llvmlistbot at llvm.org
Mon Jan 16 13:00:01 PST 2023
Author: Mahesh Ravishankar
Date: 2023-01-16T20:59:50Z
New Revision: dbbd9070152a2b1a28a1617437c75ed9491932c6
URL: https://github.com/llvm/llvm-project/commit/dbbd9070152a2b1a28a1617437c75ed9491932c6
DIFF: https://github.com/llvm/llvm-project/commit/dbbd9070152a2b1a28a1617437c75ed9491932c6.diff
LOG: [mlir][TilingInterface] Fix use after free error from D141028.
The `candidateSliceOp` was replaces and used in a subsequent
call. Instead just replace its uses. The op is dead and will be
removed with CSE.
Differential Revision: https://reviews.llvm.org/D141869
Added:
Modified:
mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h b/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
index 63d3da72a200..1ed850faa17a 100644
--- a/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
+++ b/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
@@ -90,7 +90,9 @@ struct SCFTileAndFuseOptions {
};
/// Fuse the producer of the source of `candidateSliceOp` by computing the
-/// required slice of the producer in-place.
+/// required slice of the producer in-place. Note that the method
+/// replaces the uses of `candidateSliceOp` with the tiled and fused producer
+/// value but does not delete the slice operation.
struct SCFFuseProducerOfSliceResult {
OpResult origProducer; // Original untiled producer.
Value tiledAndFusedProducer; // Tile and fused producer value.
diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index 0c3da3bd932d..cfaac283cd81 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -527,7 +527,7 @@ mlir::scf::tileAndFuseProducerOfSlice(RewriterBase &rewriter,
fusableProducer);
if (failed(fusedProducerValue))
return std::nullopt;
- rewriter.replaceOp(candidateSliceOp, fusedProducerValue.value());
+ rewriter.replaceAllUsesWith(candidateSliceOp, fusedProducerValue.value());
// 3. If the slice is for a destination operand, for example,
//
More information about the Mlir-commits
mailing list