diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp --- a/mlir/lib/IR/PatternMatch.cpp +++ b/mlir/lib/IR/PatternMatch.cpp @@ -266,7 +266,8 @@ "incorrect # of replacement values"); op->replaceAllUsesWith(newValues); - notifyOperationRemoved(op); + op->walk( + [&](Operation *op) { notifyOperationRemoved(op); }); op->erase(); } @@ -274,7 +275,8 @@ /// the given operation *must* be known to be dead. void RewriterBase::eraseOp(Operation *op) { assert(op->use_empty() && "expected 'op' to have no uses"); - notifyOperationRemoved(op); + op->walk( + [&](Operation *op) { notifyOperationRemoved(op); }); op->erase(); } diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -182,8 +182,7 @@ // If the operation is trivially dead - remove it. if (isOpTriviallyDead(op)) { - notifyOperationRemoved(op); - op->erase(); + eraseOp(op); changed = true; LLVM_DEBUG(logResultWithLine("success", "operation is trivially dead")); @@ -203,7 +202,8 @@ for (auto *userOp : result.getUsers()) addToWorklist(userOp); - notifyOperationRemoved(op); + op->walk( + [&](Operation *op) { notifyOperationRemoved(op); }); }; // Add the given operation to the worklist. @@ -350,10 +350,8 @@ }); addOperandsToWorklist(op->getOperands()); - op->walk([this](Operation *operation) { - removeFromWorklist(operation); - folder.notifyRemoval(operation); - }); + removeFromWorklist(op); + folder.notifyRemoval(op); if (config.strictMode != GreedyRewriteStrictness::AnyOp) strictModeFilteredOps.erase(op);