[Mlir-commits] [mlir] d49d83e - [MLIR][LLVM] Don't use void return type in `getCallableResults`.
Tobias Gysi
llvmlistbot at llvm.org
Thu Jan 19 01:01:59 PST 2023
Author: Johannes de Fine Licht
Date: 2023-01-19T10:01:22+01:00
New Revision: d49d83e79ca0b59c3d68ff6c46eea69d848b0617
URL: https://github.com/llvm/llvm-project/commit/d49d83e79ca0b59c3d68ff6c46eea69d848b0617
DIFF: https://github.com/llvm/llvm-project/commit/d49d83e79ca0b59c3d68ff6c46eea69d848b0617.diff
LOG: [MLIR][LLVM] Don't use void return type in `getCallableResults`.
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
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index a97073e792afd..88eacda36c2e9 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -1520,8 +1520,14 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
/// 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();
+ }
}];
More information about the Mlir-commits
mailing list