[PATCH] D71961: [MLIR] Free ReturnOp from being restricted to a FuncOp

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 01:37:08 PDT 2020


bondhugula added a comment.

In D71961#1948401 <https://reviews.llvm.org/D71961#1948401>, @mehdi_amini wrote:

> FYI I still believe that a good first step her would be to use something like the FunctionLike trait to constraint the parent of the return op.


This was already discussed at the comment thread at Ops.cpp line 1968 in the first diff - (see River's/my comments). The FunctionLike trait here isn't a perfect fit here because there are ops that have the FunctionLike trait but don't model their function return type in the same way (like llvm.func) and thus you can't do a funcOp.getType().getResults() in the verifier. The right way to handle that is through an op interface (so that a FuncLikeOp::getType() provides the uniform behavior needed for verify), and so we agreed on adding a TODO comment for it there. Note that if a FunctionLike trait op needs something custom for its return type, it just shouldn't use std.return - even if it does, the verifier would fail for its needs. There are ops of course with a FunctionLike trait that could reuse std.return, and in those cases they'd better use the TODO FuncLikeOpInterface. There is still no need to restrict the parent to those implementing FuncLikeOpInterface. FYI, I've updated the op ODS description to add a clear guideline at the end. (Also, see the discussion thread with @silvas where I mention why CFG transformations would want to see the same terminator on FuncOp as well as std.execute_region - instead of having to do isa/dyn_cast<ReturnOp> || isa/dyn_cast<yield op / some other alias of return>)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71961/new/

https://reviews.llvm.org/D71961





More information about the llvm-commits mailing list