Skip to content

Commit cfd54ec

Browse files
matthias-springermgehre-amd
authored andcommitted
[mlir][EmitC] Fix invalid rewriter API usage (llvm#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.
1 parent 8362127 commit cfd54ec

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

mlir/lib/Dialect/EmitC/Transforms/Transforms.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ struct FoldExpressionOp : public OpRewritePattern<ExpressionOp> {
9696
assert(clonedExpressionRootOp->getNumResults() == 1 &&
9797
"Expected cloned root to have a single result");
9898

99-
Value clonedExpressionResult = clonedExpressionRootOp->getResult(0);
100-
101-
usedExpression.getResult().replaceAllUsesWith(clonedExpressionResult);
102-
rewriter.eraseOp(usedExpression);
99+
rewriter.replaceOp(usedExpression, clonedExpressionRootOp);
103100
anythingFolded = true;
104101
}
105102
}

0 commit comments

Comments
 (0)