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
Loading
Please sign in to comment