In the LLVM IR dialect, `LLVMVoidType` is used to model the return type
of LLVM IR functions with no return value. This is inconsistent with
MLIR APIs, which expect a function with no return value to have an
empty return type. Handle this special case in `LLVMFuncOp` to avoid
mismatches between the number of return values and return types between
caller and callee.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D141676
/// is external, returns null.
Region *getCallableRegion();
- /// Returns the callable result type, which is the function return type.
- ArrayRef<Type> getCallableResults() { return getFunctionType().getReturnTypes(); }
+ /// Returns the callable result type, which is the single function return
+ /// type if it is not void, or an empty array if the function's return type
+ /// is void, as void is not assignable to a value.
+ ArrayRef<Type> getCallableResults() {
+ if (getFunctionType().getReturnType().isa<LLVM::LLVMVoidType>())
+ return {};
+ return getFunctionType().getReturnTypes();
+ }
}];