Move the ReturnOp type checks to ReturnOp::verify.

This was left as a TODO in the code.  Move the type verification from
MLFuncVerifier::verifyReturn to ReturnOp::verify.  Since the return operation
can only appear as the last statement of an MLFunction, i.e. where the
surrounding block is the function itself, it is easy to access the function
descriptor (ReturnOp::verify already relies on this).  From the function
descriptor, one can easily access the type information.  Note that this
slightly modifies the error message due to the use of emitOpError instead of a
plain emitError.

Drop the obsolete TODO comment in MLFunction::verify about checking that
"return" only appears as the last operation of an MLFunction since
ReturnOp::verify explicitly checks for that.
PiperOrigin-RevId: 218347843
3 files changed
tree: 8d1cab259c985bb96fd594d74c98115ae4361fe1
  1. include/
  2. lib/
  3. test/
  4. tools/
  5. utils/
  6. .clang-format
  7. LICENSE.TXT