[Mlir-commits] [mlir] [mlir][EmitC] Fix invalid rewriter API usage (PR #76124)
Matthias Springer
llvmlistbot at llvm.org
Wed Dec 20 21:18:48 PST 2023
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/76124
When operations are modified in-place, the rewriter must be notified. This commit fixes `mlir/test/Dialect/EmitC/transforms.mlir` when running with `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` enabled.
>From 6c0508c50ca16b8cd0d3bb81b12d4af2c2faed25 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Thu, 21 Dec 2023 14:15:58 +0900
Subject: [PATCH] [mlir][EmitC] Fix invalid rewriter API usage
When operations are modified in-place, the rewriter must be notified. This commit fixes `mlir/test/Dialect/EmitC/transforms.mlir` when running with `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` enabled.
---
mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp b/mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp
index 593d774cac73bd..88b691b50f325d 100644
--- a/mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp
@@ -96,10 +96,7 @@ struct FoldExpressionOp : public OpRewritePattern<ExpressionOp> {
assert(clonedExpressionRootOp->getNumResults() == 1 &&
"Expected cloned root to have a single result");
- Value clonedExpressionResult = clonedExpressionRootOp->getResult(0);
-
- usedExpression.getResult().replaceAllUsesWith(clonedExpressionResult);
- rewriter.eraseOp(usedExpression);
+ rewriter.replaceOp(usedExpression, clonedExpressionRootOp);
anythingFolded = true;
}
}
More information about the Mlir-commits
mailing list