summaryrefslogtreecommitdiff
path: root/mlir/test
diff options
context:
space:
mode:
authorMatthias Springer <me@m-sp.org>2023-05-15 14:39:50 +0200
committerMatthias Springer <me@m-sp.org>2023-05-15 14:40:42 +0200
commite219e66e442ba630ff21fdd495df705b3d485d41 (patch)
treea0fb6231a15e41b465a3d0e947f8f398e9769dd5 /mlir/test
parent38bef476552021b7ad45d1aa989d250bcd0a38ff (diff)
downloadllvm-e219e66e442ba630ff21fdd495df705b3d485d41.tar.gz
[mlir][IR][tests] Fix incorrect API usage in RewritePatterns
Incorrect API usage was detected by D144552. Differential Revision: https://reviews.llvm.org/D145167
Diffstat (limited to 'mlir/test')
-rw-r--r--mlir/test/lib/Dialect/Test/TestPatterns.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index a61ba8e47e3e..82ae72ab6a27 100644
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -192,7 +192,9 @@ struct HoistEligibleOps : public OpRewritePattern<test::OneRegionOp> {
return failure();
if (!toBeHoisted->hasAttr("eligible"))
return failure();
- toBeHoisted->moveBefore(op);
+ // Hoisting means removing an op from the enclosing op. I.e., the enclosing
+ // op is modified.
+ rewriter.updateRootInPlace(op, [&]() { toBeHoisted->moveBefore(op); });
return success();
}
};
@@ -316,7 +318,8 @@ private:
Operation *newOp =
rewriter.create(op->getLoc(), op->getName().getIdentifier(),
op->getOperands(), op->getResultTypes());
- op->setAttr("skip", rewriter.getBoolAttr(true));
+ rewriter.updateRootInPlace(
+ op, [&]() { op->setAttr("skip", rewriter.getBoolAttr(true)); });
newOp->setAttr("skip", rewriter.getBoolAttr(true));
return success();