@@ -986,20 +986,25 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
986
986
if (!skip_debug_info) {
987
987
bool first_arg_return = calling_convention_does_first_arg_return (fn_type_id->cc ) &&
988
988
handle_is_ptr (fn_type_id->return_type );
989
+ bool is_async = fn_type_id->cc == CallingConventionAsync;
989
990
bool prefix_arg_error_return_trace = g->have_err_ret_tracing &&
990
991
(fn_type_id->return_type ->id == TypeTableEntryIdErrorUnion ||
991
992
fn_type_id->return_type ->id == TypeTableEntryIdErrorSet);
992
993
// +1 for maybe making the first argument the return value
993
- // +1 for maybe last argument the error return trace
994
- LLVMTypeRef *gen_param_types = allocate<LLVMTypeRef>(2 + fn_type_id->param_count );
994
+ // +1 for maybe first argument the error return trace
995
+ // +2 for maybe arguments async allocator and error code pointer
996
+ LLVMTypeRef *gen_param_types = allocate<LLVMTypeRef>(4 + fn_type_id->param_count );
995
997
// +1 because 0 is the return type and
996
998
// +1 for maybe making first arg ret val and
997
- // +1 for maybe last argument the error return trace
998
- ZigLLVMDIType **param_di_types = allocate<ZigLLVMDIType*>(3 + fn_type_id->param_count );
999
+ // +1 for maybe first argument the error return trace
1000
+ // +2 for maybe arguments async allocator and error code pointer
1001
+ ZigLLVMDIType **param_di_types = allocate<ZigLLVMDIType*>(5 + fn_type_id->param_count );
999
1002
param_di_types[0 ] = fn_type_id->return_type ->di_type ;
1000
1003
size_t gen_param_index = 0 ;
1001
1004
TypeTableEntry *gen_return_type;
1002
- if (!type_has_bits (fn_type_id->return_type )) {
1005
+ if (is_async) {
1006
+ gen_return_type = get_pointer_to_type (g, g->builtin_types .entry_u8 , false );
1007
+ } else if (!type_has_bits (fn_type_id->return_type )) {
1003
1008
gen_return_type = g->builtin_types .entry_void ;
1004
1009
} else if (first_arg_return) {
1005
1010
TypeTableEntry *gen_type = get_pointer_to_type (g, fn_type_id->return_type , false );
@@ -1020,6 +1025,25 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1020
1025
// after the gen_param_index += 1 because 0 is the return type
1021
1026
param_di_types[gen_param_index] = gen_type->di_type ;
1022
1027
}
1028
+ if (is_async) {
1029
+ {
1030
+ // async allocator param
1031
+ TypeTableEntry *gen_type = fn_type_id->async_allocator_type ;
1032
+ gen_param_types[gen_param_index] = gen_type->type_ref ;
1033
+ gen_param_index += 1 ;
1034
+ // after the gen_param_index += 1 because 0 is the return type
1035
+ param_di_types[gen_param_index] = gen_type->di_type ;
1036
+ }
1037
+
1038
+ {
1039
+ // error code pointer
1040
+ TypeTableEntry *gen_type = get_pointer_to_type (g, g->builtin_types .entry_global_error_set , false );
1041
+ gen_param_types[gen_param_index] = gen_type->type_ref ;
1042
+ gen_param_index += 1 ;
1043
+ // after the gen_param_index += 1 because 0 is the return type
1044
+ param_di_types[gen_param_index] = gen_type->di_type ;
1045
+ }
1046
+ }
1023
1047
1024
1048
fn_type->data .fn .gen_param_info = allocate<FnGenParamInfo>(fn_type_id->param_count );
1025
1049
for (size_t i = 0 ; i < fn_type_id->param_count ; i += 1 ) {
0 commit comments