From: Vladislav Vinogradov Date: Tue, 2 Feb 2021 18:33:08 +0000 (+0000) Subject: [mlir] Return new Operation from `Rewriter::replaceOpWithNewOp` X-Git-Tag: llvmorg-14-init~16237 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67dfe9c8d70c1242c1e91e3bafc710781ac2a585;p=platform%2Fupstream%2Fllvm.git [mlir] Return new Operation from `Rewriter::replaceOpWithNewOp` It will allow to perform additional manipulation with the newly created Operation. For example, custom attributes propagation/changes. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D95525 --- diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 1a306e6..04904da 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -480,9 +480,10 @@ public: /// Replaces the result op with a new op that is created without verification. /// The result values of the two ops must be the same types. template - void replaceOpWithNewOp(Operation *op, Args &&... args) { + OpTy replaceOpWithNewOp(Operation *op, Args &&... args) { auto newOp = create(op->getLoc(), std::forward(args)...); replaceOpWithResultsOfAnotherOp(op, newOp.getOperation()); + return newOp; } /// This method erases an operation that is known to have no uses.