[mlir][bufferize] Fix tracking of erased ops
authorMatthias Springer <me@m-sp.org>
Mon, 27 Mar 2023 06:57:46 +0000 (08:57 +0200)
committerMatthias Springer <me@m-sp.org>
Mon, 27 Mar 2023 06:58:53 +0000 (08:58 +0200)
This is a workaround until D144193 has landed.

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

mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp

index 0b10baf..e5e125f 100644 (file)
@@ -358,9 +358,12 @@ public:
 
 protected:
   void notifyOperationRemoved(Operation *op) override {
-    erasedOps.insert(op);
-    // Erase if present.
-    toMemrefOps.erase(op);
+    // TODO: Walk can be removed when D144193 has landed.
+    op->walk([&](Operation *op) {
+      erasedOps.insert(op);
+      // Erase if present.
+      toMemrefOps.erase(op);
+    });
   }
 
   void notifyOperationInserted(Operation *op) override {