| ... | ... | @@ -1382,7 +1382,7 @@ static IrInstruction *ir_build_union_field_ptr(IrBuilder *irb, Scope *scope, Ast |
| 1382 | 1382 | |
| 1383 | 1383 | static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1384 | 1384 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, |
| 1385 | | bool is_comptime, FnInline fn_inline, bool is_async, |
| 1385 | bool is_comptime, FnInline fn_inline, bool is_async, bool is_async_call_builtin, |
| 1386 | 1386 | IrInstruction *new_stack, ResultLoc *result_loc) |
| 1387 | 1387 | { |
| 1388 | 1388 | IrInstructionCallSrc *call_instruction = ir_build_instruction<IrInstructionCallSrc>(irb, scope, source_node); |
| ... | ... | @@ -1393,6 +1393,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s |
| 1393 | 1393 | call_instruction->args = args; |
| 1394 | 1394 | call_instruction->arg_count = arg_count; |
| 1395 | 1395 | call_instruction->is_async = is_async; |
| 1396 | call_instruction->is_async_call_builtin = is_async_call_builtin; |
| 1396 | 1397 | call_instruction->new_stack = new_stack; |
| 1397 | 1398 | call_instruction->result_loc = result_loc; |
| 1398 | 1399 | |
| ... | ... | @@ -1410,7 +1411,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s |
| 1410 | 1411 | |
| 1411 | 1412 | static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *source_instruction, |
| 1412 | 1413 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, |
| 1413 | | FnInline fn_inline, bool is_async, IrInstruction *new_stack, |
| 1414 | FnInline fn_inline, bool is_async, IrInstruction *new_stack, bool is_async_call_builtin, |
| 1414 | 1415 | IrInstruction *result_loc, ZigType *return_type) |
| 1415 | 1416 | { |
| 1416 | 1417 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, |
| ... | ... | @@ -1422,6 +1423,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so |
| 1422 | 1423 | call_instruction->args = args; |
| 1423 | 1424 | call_instruction->arg_count = arg_count; |
| 1424 | 1425 | call_instruction->is_async = is_async; |
| 1426 | call_instruction->is_async_call_builtin = is_async_call_builtin; |
| 1425 | 1427 | call_instruction->new_stack = new_stack; |
| 1426 | 1428 | call_instruction->result_loc = result_loc; |
| 1427 | 1429 | |
| ... | ... | @@ -4351,6 +4353,54 @@ static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *no |
| 4351 | 4353 | zig_unreachable(); |
| 4352 | 4354 | } |
| 4353 | 4355 | |
| 4356 | static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *await_node, AstNode *call_node, |
| 4357 | LVal lval, ResultLoc *result_loc) |
| 4358 | { |
| 4359 | size_t arg_offset = 3; |
| 4360 | if (call_node->data.fn_call_expr.params.length < arg_offset) { |
| 4361 | add_node_error(irb->codegen, call_node, |
| 4362 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 4363 | arg_offset, call_node->data.fn_call_expr.params.length)); |
| 4364 | return irb->codegen->invalid_instruction; |
| 4365 | } |
| 4366 | |
| 4367 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); |
| 4368 | IrInstruction *bytes = ir_gen_node(irb, bytes_node, scope); |
| 4369 | if (bytes == irb->codegen->invalid_instruction) |
| 4370 | return bytes; |
| 4371 | |
| 4372 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); |
| 4373 | IrInstruction *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); |
| 4374 | if (ret_ptr == irb->codegen->invalid_instruction) |
| 4375 | return ret_ptr; |
| 4376 | |
| 4377 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); |
| 4378 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 4379 | if (fn_ref == irb->codegen->invalid_instruction) |
| 4380 | return fn_ref; |
| 4381 | |
| 4382 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; |
| 4383 | |
| 4384 | // last "arg" is return pointer |
| 4385 | IrInstruction **args = allocate<IrInstruction*>(arg_count + 1); |
| 4386 | |
| 4387 | for (size_t i = 0; i < arg_count; i += 1) { |
| 4388 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); |
| 4389 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); |
| 4390 | if (arg == irb->codegen->invalid_instruction) |
| 4391 | return arg; |
| 4392 | args[i] = arg; |
| 4393 | } |
| 4394 | |
| 4395 | args[arg_count] = ret_ptr; |
| 4396 | |
| 4397 | bool is_async = await_node == nullptr; |
| 4398 | bool is_async_call_builtin = true; |
| 4399 | IrInstruction *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, false, |
| 4400 | FnInlineAuto, is_async, is_async_call_builtin, bytes, result_loc); |
| 4401 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 4402 | } |
| 4403 | |
| 4354 | 4404 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, |
| 4355 | 4405 | ResultLoc *result_loc) |
| 4356 | 4406 | { |
| ... | ... | @@ -4360,7 +4410,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4360 | 4410 | Buf *name = fn_ref_expr->data.symbol_expr.symbol; |
| 4361 | 4411 | auto entry = irb->codegen->builtin_fn_table.maybe_get(name); |
| 4362 | 4412 | |
| 4363 | | if (!entry) { // new built in not found |
| 4413 | if (!entry) { |
| 4364 | 4414 | add_node_error(irb->codegen, node, |
| 4365 | 4415 | buf_sprintf("invalid builtin function: '%s'", buf_ptr(name))); |
| 4366 | 4416 | return irb->codegen->invalid_instruction; |
| ... | ... | @@ -5224,7 +5274,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5224 | 5274 | FnInline fn_inline = (builtin_fn->id == BuiltinFnIdInlineCall) ? FnInlineAlways : FnInlineNever; |
| 5225 | 5275 | |
| 5226 | 5276 | IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false, |
| 5227 | | fn_inline, false, nullptr, result_loc); |
| 5277 | fn_inline, false, false, nullptr, result_loc); |
| 5228 | 5278 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 5229 | 5279 | } |
| 5230 | 5280 | case BuiltinFnIdNewStackCall: |
| ... | ... | @@ -5257,53 +5307,11 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5257 | 5307 | } |
| 5258 | 5308 | |
| 5259 | 5309 | IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false, |
| 5260 | | FnInlineAuto, false, new_stack, result_loc); |
| 5310 | FnInlineAuto, false, false, new_stack, result_loc); |
| 5261 | 5311 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 5262 | 5312 | } |
| 5263 | 5313 | case BuiltinFnIdAsyncCall: |
| 5264 | | { |
| 5265 | | size_t arg_offset = 3; |
| 5266 | | if (node->data.fn_call_expr.params.length < arg_offset) { |
| 5267 | | add_node_error(irb->codegen, node, |
| 5268 | | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 5269 | | arg_offset, node->data.fn_call_expr.params.length)); |
| 5270 | | return irb->codegen->invalid_instruction; |
| 5271 | | } |
| 5272 | | |
| 5273 | | AstNode *bytes_node = node->data.fn_call_expr.params.at(0); |
| 5274 | | IrInstruction *bytes = ir_gen_node(irb, bytes_node, scope); |
| 5275 | | if (bytes == irb->codegen->invalid_instruction) |
| 5276 | | return bytes; |
| 5277 | | |
| 5278 | | AstNode *ret_ptr_node = node->data.fn_call_expr.params.at(1); |
| 5279 | | IrInstruction *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); |
| 5280 | | if (ret_ptr == irb->codegen->invalid_instruction) |
| 5281 | | return ret_ptr; |
| 5282 | | |
| 5283 | | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(2); |
| 5284 | | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 5285 | | if (fn_ref == irb->codegen->invalid_instruction) |
| 5286 | | return fn_ref; |
| 5287 | | |
| 5288 | | size_t arg_count = node->data.fn_call_expr.params.length - arg_offset; |
| 5289 | | |
| 5290 | | // last "arg" is return pointer |
| 5291 | | IrInstruction **args = allocate<IrInstruction*>(arg_count + 1); |
| 5292 | | |
| 5293 | | for (size_t i = 0; i < arg_count; i += 1) { |
| 5294 | | AstNode *arg_node = node->data.fn_call_expr.params.at(i + arg_offset); |
| 5295 | | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); |
| 5296 | | if (arg == irb->codegen->invalid_instruction) |
| 5297 | | return arg; |
| 5298 | | args[i] = arg; |
| 5299 | | } |
| 5300 | | |
| 5301 | | args[arg_count] = ret_ptr; |
| 5302 | | |
| 5303 | | IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false, |
| 5304 | | FnInlineAuto, true, bytes, result_loc); |
| 5305 | | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 5306 | | } |
| 5314 | return ir_gen_async_call(irb, scope, nullptr, node, lval, result_loc); |
| 5307 | 5315 | case BuiltinFnIdTypeId: |
| 5308 | 5316 | { |
| 5309 | 5317 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -5607,7 +5615,7 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node |
| 5607 | 5615 | |
| 5608 | 5616 | bool is_async = node->data.fn_call_expr.is_async; |
| 5609 | 5617 | IrInstruction *fn_call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false, |
| 5610 | | FnInlineAuto, is_async, nullptr, result_loc); |
| 5618 | FnInlineAuto, is_async, false, nullptr, result_loc); |
| 5611 | 5619 | return ir_lval_wrap(irb, scope, fn_call, lval, result_loc); |
| 5612 | 5620 | } |
| 5613 | 5621 | |
| ... | ... | @@ -7900,6 +7908,19 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7900 | 7908 | { |
| 7901 | 7909 | assert(node->type == NodeTypeAwaitExpr); |
| 7902 | 7910 | |
| 7911 | AstNode *expr_node = node->data.await_expr.expr; |
| 7912 | if (expr_node->type == NodeTypeFnCallExpr && expr_node->data.fn_call_expr.is_builtin) { |
| 7913 | AstNode *fn_ref_expr = expr_node->data.fn_call_expr.fn_ref_expr; |
| 7914 | Buf *name = fn_ref_expr->data.symbol_expr.symbol; |
| 7915 | auto entry = irb->codegen->builtin_fn_table.maybe_get(name); |
| 7916 | if (entry != nullptr) { |
| 7917 | BuiltinFnEntry *builtin_fn = entry->value; |
| 7918 | if (builtin_fn->id == BuiltinFnIdAsyncCall) { |
| 7919 | return ir_gen_async_call(irb, scope, node, expr_node, lval, result_loc); |
| 7920 | } |
| 7921 | } |
| 7922 | } |
| 7923 | |
| 7903 | 7924 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 7904 | 7925 | if (!fn_entry) { |
| 7905 | 7926 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); |
| ... | ... | @@ -7915,7 +7936,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7915 | 7936 | return irb->codegen->invalid_instruction; |
| 7916 | 7937 | } |
| 7917 | 7938 | |
| 7918 | | IrInstruction *target_inst = ir_gen_node_extra(irb, node->data.await_expr.expr, scope, LValPtr, nullptr); |
| 7939 | IrInstruction *target_inst = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 7919 | 7940 | if (target_inst == irb->codegen->invalid_instruction) |
| 7920 | 7941 | return irb->codegen->invalid_instruction; |
| 7921 | 7942 | |
| ... | ... | @@ -15244,44 +15265,61 @@ static IrInstruction *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInst |
| 15244 | 15265 | return ir_const_void(ira, &instruction->base); |
| 15245 | 15266 | } |
| 15246 | 15267 | |
| 15268 | static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, |
| 15269 | ZigType *fn_ret_type) |
| 15270 | { |
| 15271 | ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base); |
| 15272 | IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child; |
| 15273 | if (type_is_invalid(ret_ptr_uncasted->value.type)) |
| 15274 | return ira->codegen->invalid_instruction; |
| 15275 | if (ret_ptr_uncasted->value.type->id == ZigTypeIdVoid) { |
| 15276 | // Result location will be inside the async frame. |
| 15277 | return nullptr; |
| 15278 | } |
| 15279 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 15280 | } |
| 15281 | |
| 15247 | 15282 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry, |
| 15248 | 15283 | ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, |
| 15249 | 15284 | IrInstruction *casted_new_stack) |
| 15250 | 15285 | { |
| 15251 | | if (casted_new_stack != nullptr) { |
| 15252 | | // this is an @asyncCall |
| 15253 | | |
| 15286 | if (fn_entry == nullptr) { |
| 15254 | 15287 | if (fn_type->data.fn.fn_type_id.cc != CallingConventionAsync) { |
| 15255 | 15288 | ir_add_error(ira, fn_ref, |
| 15256 | 15289 | buf_sprintf("expected async function, found '%s'", buf_ptr(&fn_type->name))); |
| 15257 | 15290 | return ira->codegen->invalid_instruction; |
| 15258 | 15291 | } |
| 15259 | | |
| 15260 | | IrInstruction *ret_ptr = call_instruction->args[call_instruction->arg_count]->child; |
| 15261 | | if (type_is_invalid(ret_ptr->value.type)) |
| 15292 | if (casted_new_stack == nullptr) { |
| 15293 | ir_add_error(ira, fn_ref, buf_sprintf("function is not comptime-known; @asyncCall required")); |
| 15294 | return ira->codegen->invalid_instruction; |
| 15295 | } |
| 15296 | } |
| 15297 | if (casted_new_stack != nullptr) { |
| 15298 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 15299 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, call_instruction, fn_ret_type); |
| 15300 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value.type)) |
| 15262 | 15301 | return ira->codegen->invalid_instruction; |
| 15263 | 15302 | |
| 15264 | | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_type->data.fn.fn_type_id.return_type); |
| 15303 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| 15265 | 15304 | |
| 15266 | | IrInstructionCallGen *call_gen = ir_build_call_gen(ira, &call_instruction->base, nullptr, fn_ref, |
| 15267 | | arg_count, casted_args, FnInlineAuto, true, casted_new_stack, ret_ptr, anyframe_type); |
| 15305 | IrInstructionCallGen *call_gen = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, |
| 15306 | arg_count, casted_args, FnInlineAuto, true, casted_new_stack, |
| 15307 | call_instruction->is_async_call_builtin, ret_ptr, anyframe_type); |
| 15268 | 15308 | return &call_gen->base; |
| 15269 | | } else if (fn_entry == nullptr) { |
| 15270 | | ir_add_error(ira, fn_ref, buf_sprintf("function is not comptime-known; @asyncCall required")); |
| 15271 | | return ira->codegen->invalid_instruction; |
| 15272 | | } |
| 15273 | | |
| 15274 | | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 15275 | | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 15276 | | frame_type, nullptr, true, true, false); |
| 15277 | | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { |
| 15278 | | return result_loc; |
| 15309 | } else { |
| 15310 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 15311 | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 15312 | frame_type, nullptr, true, true, false); |
| 15313 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { |
| 15314 | return result_loc; |
| 15315 | } |
| 15316 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 15317 | if (type_is_invalid(result_loc->value.type)) |
| 15318 | return ira->codegen->invalid_instruction; |
| 15319 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, |
| 15320 | casted_args, FnInlineAuto, true, casted_new_stack, call_instruction->is_async_call_builtin, |
| 15321 | result_loc, frame_type)->base; |
| 15279 | 15322 | } |
| 15280 | | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 15281 | | if (type_is_invalid(result_loc->value.type)) |
| 15282 | | return ira->codegen->invalid_instruction; |
| 15283 | | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, |
| 15284 | | casted_args, FnInlineAuto, true, nullptr, result_loc, frame_type)->base; |
| 15285 | 15323 | } |
| 15286 | 15324 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 15287 | 15325 | IrInstruction *arg, Scope **exec_scope, size_t *next_proto_i) |
| ... | ... | @@ -15790,16 +15828,27 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 15790 | 15828 | |
| 15791 | 15829 | IrInstruction *casted_new_stack = nullptr; |
| 15792 | 15830 | if (call_instruction->new_stack != nullptr) { |
| 15793 | | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 15794 | | false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false); |
| 15795 | | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 15796 | 15831 | IrInstruction *new_stack = call_instruction->new_stack->child; |
| 15797 | 15832 | if (type_is_invalid(new_stack->value.type)) |
| 15798 | 15833 | return ira->codegen->invalid_instruction; |
| 15799 | 15834 | |
| 15800 | | casted_new_stack = ir_implicit_cast(ira, new_stack, u8_slice); |
| 15801 | | if (type_is_invalid(casted_new_stack->value.type)) |
| 15802 | | return ira->codegen->invalid_instruction; |
| 15835 | if (call_instruction->is_async_call_builtin && |
| 15836 | fn_entry != nullptr && new_stack->value.type->id == ZigTypeIdPointer && |
| 15837 | new_stack->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 15838 | { |
| 15839 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, |
| 15840 | get_fn_frame_type(ira->codegen, fn_entry), false); |
| 15841 | casted_new_stack = ir_implicit_cast(ira, new_stack, needed_frame_type); |
| 15842 | if (type_is_invalid(casted_new_stack->value.type)) |
| 15843 | return ira->codegen->invalid_instruction; |
| 15844 | } else { |
| 15845 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 15846 | false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false); |
| 15847 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 15848 | casted_new_stack = ir_implicit_cast(ira, new_stack, u8_slice); |
| 15849 | if (type_is_invalid(casted_new_stack->value.type)) |
| 15850 | return ira->codegen->invalid_instruction; |
| 15851 | } |
| 15803 | 15852 | } |
| 15804 | 15853 | |
| 15805 | 15854 | if (fn_type->data.fn.is_generic) { |
| ... | ... | @@ -16010,7 +16059,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 16010 | 16059 | |
| 16011 | 16060 | FnTypeId *impl_fn_type_id = &impl_fn->type_entry->data.fn.fn_type_id; |
| 16012 | 16061 | IrInstruction *result_loc; |
| 16013 | | if (handle_is_ptr(impl_fn_type_id->return_type)) { |
| 16062 | if (call_instruction->is_async_call_builtin) { |
| 16063 | result_loc = get_async_call_result_loc(ira, call_instruction, impl_fn_type_id->return_type); |
| 16064 | if (result_loc != nullptr && type_is_invalid(result_loc->value.type)) |
| 16065 | return ira->codegen->invalid_instruction; |
| 16066 | } else if (handle_is_ptr(impl_fn_type_id->return_type)) { |
| 16014 | 16067 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 16015 | 16068 | impl_fn_type_id->return_type, nullptr, true, true, false); |
| 16016 | 16069 | if (result_loc != nullptr) { |
| ... | ... | @@ -16044,7 +16097,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 16044 | 16097 | |
| 16045 | 16098 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base, |
| 16046 | 16099 | impl_fn, nullptr, impl_param_count, casted_args, fn_inline, |
| 16047 | | false, casted_new_stack, result_loc, |
| 16100 | false, casted_new_stack, call_instruction->is_async_call_builtin, result_loc, |
| 16048 | 16101 | impl_fn_type_id->return_type); |
| 16049 | 16102 | |
| 16050 | 16103 | parent_fn_entry->call_list.append(new_call_instruction); |
| ... | ... | @@ -16167,7 +16220,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 16167 | 16220 | } |
| 16168 | 16221 | |
| 16169 | 16222 | IrInstruction *result_loc; |
| 16170 | | if (handle_is_ptr(return_type)) { |
| 16223 | if (call_instruction->is_async_call_builtin) { |
| 16224 | result_loc = get_async_call_result_loc(ira, call_instruction, return_type); |
| 16225 | if (result_loc != nullptr && type_is_invalid(result_loc->value.type)) |
| 16226 | return ira->codegen->invalid_instruction; |
| 16227 | } else if (handle_is_ptr(return_type)) { |
| 16171 | 16228 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 16172 | 16229 | return_type, nullptr, true, true, false); |
| 16173 | 16230 | if (result_loc != nullptr) { |
| ... | ... | @@ -16185,7 +16242,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 16185 | 16242 | |
| 16186 | 16243 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, |
| 16187 | 16244 | call_param_count, casted_args, fn_inline, false, casted_new_stack, |
| 16188 | | result_loc, return_type); |
| 16245 | call_instruction->is_async_call_builtin, result_loc, return_type); |
| 16189 | 16246 | parent_fn_entry->call_list.append(new_call_instruction); |
| 16190 | 16247 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 16191 | 16248 | } |