[Mlir-commits] [mlir] e219e66 - [mlir][IR][tests] Fix incorrect API usage in RewritePatterns

Matthias Springer llvmlistbot at llvm.org
Mon May 15 05:46:21 PDT 2023


Author: Matthias Springer
Date: 2023-05-15T14:40:42+02:00
New Revision: e219e66e442ba630ff21fdd495df705b3d485d41

URL: https://github.com/llvm/llvm-project/commit/e219e66e442ba630ff21fdd495df705b3d485d41
DIFF: https://github.com/llvm/llvm-project/commit/e219e66e442ba630ff21fdd495df705b3d485d41.diff

LOG: [mlir][IR][tests] Fix incorrect API usage in RewritePatterns

Incorrect API usage was detected by D144552.

Differential Revision: https://reviews.llvm.org/D145167

Added: 
    

Modified: 
    mlir/test/lib/Dialect/Test/TestPatterns.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index a61ba8e47e3e8..82ae72ab6a27d 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 @@ struct TestStrictPatternDriver
       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();


        


More information about the Mlir-commits mailing list