diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -601,17 +601,11 @@ template class OneResult : public TraitBase { public: - Value getResult() { return this->getOperation()->getResult(0); } - - /// If the operation returns a single value, then the Op can be implicitly - /// converted to an Value. This yields the value of the only result. - operator Value() { return getResult(); } - /// Replace all uses of 'this' value with the new value, updating anything /// in the IR that uses 'this' to use the other value instead. When this /// returns there are zero uses of 'this'. void replaceAllUsesWith(Value newValue) { - getResult().replaceAllUsesWith(newValue); + this->getOperation()->getResult(0).replaceAllUsesWith(newValue); } /// Replace all uses of 'this' value with the result of 'op'. @@ -637,10 +631,15 @@ class Impl : public TraitBase::Impl> { public: - ResultType getType() { - auto resultTy = this->getOperation()->getResult(0).getType(); - return resultTy.template cast(); + TypedValue getResult() { + return this->getOperation()->getResult(0); } + + /// If the operation returns a single value, then the Op can be implicitly + /// converted to a Value. This yields the value of the only result. + operator TypedValue() { return getResult(); } + + ResultType getType() { return getResult().getType(); } }; }; diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -579,7 +579,7 @@ auto illegalOp = rewriter.create(op->getLoc(), rewriter.getF32Type()); rewriter.replaceUsesOfBlockArgument(op->getRegion(0).getArgument(0), - illegalOp); + illegalOp->getResult(0)); rewriter.updateRootInPlace(op, [] {}); return success(); }