diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -506,6 +506,13 @@ /// modified uses and notifies the rewriter that an in-place operation /// modification is about to happen. void replaceAllUsesWith(Value from, Value to); + template + void replaceAllUsesWith(IRObjectWithUseList *from, ValueT &&to) { + for (OperandType &operand : llvm::make_early_inc_range(from->getUses())) { + Operation *op = operand.getOwner(); + updateRootInPlace(op, [&]() { operand.set(to); }); + } + } /// Find uses of `from` and replace them with `to` if the `functor` returns /// true. It also marks every modified uses and notifies the rewriter that an