| ... | ... | @@ -5884,7 +5884,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 5884 | 5884 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); |
| 5885 | 5885 | incoming_blocks[0] = entry_block; |
| 5886 | 5886 | incoming_values[0] = null_ptr; |
| 5887 | | incoming_blocks[1] = dyn_alloc_block; |
| 5887 | incoming_blocks[1] = alloc_ok_block; |
| 5888 | 5888 | incoming_values[1] = coro_mem_ptr; |
| 5889 | 5889 | IrInstruction *coro_mem = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values); |
| 5890 | 5890 | irb->exec->coro_handle = ir_build_coro_begin(irb, scope, node, coro_id, coro_mem); |
| ... | ... | @@ -10897,7 +10897,13 @@ static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 10897 | 10897 | return ira->codegen->builtin_types.entry_type; |
| 10898 | 10898 | } |
| 10899 | 10899 | |
| 10900 | | IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_instr, FnTableEntry *parent_fn_entry) { |
| 10900 | IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_instr) { |
| 10901 | FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 10902 | if (parent_fn_entry == nullptr) { |
| 10903 | ir_add_error(ira, source_instr, buf_sprintf("no implicit allocator available")); |
| 10904 | return ira->codegen->invalid_instruction; |
| 10905 | } |
| 10906 | |
| 10901 | 10907 | FnTypeId *parent_fn_type = &parent_fn_entry->type_entry->data.fn.fn_type_id; |
| 10902 | 10908 | if (parent_fn_type->cc != CallingConventionAsync) { |
| 10903 | 10909 | ir_add_error(ira, source_instr, buf_sprintf("async function call from non-async caller requires allocator parameter")); |
| ... | ... | @@ -11467,7 +11473,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 11467 | 11473 | } |
| 11468 | 11474 | IrInstruction *uncasted_async_allocator_inst; |
| 11469 | 11475 | if (call_instruction->async_allocator == nullptr) { |
| 11470 | | uncasted_async_allocator_inst = ir_get_implicit_allocator(ira, &call_instruction->base, parent_fn_entry); |
| 11476 | uncasted_async_allocator_inst = ir_get_implicit_allocator(ira, &call_instruction->base); |
| 11471 | 11477 | if (type_is_invalid(uncasted_async_allocator_inst->value.type)) |
| 11472 | 11478 | return ira->codegen->builtin_types.entry_invalid; |
| 11473 | 11479 | } else { |
| ... | ... | @@ -11586,7 +11592,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 11586 | 11592 | if (call_instruction->is_async) { |
| 11587 | 11593 | IrInstruction *uncasted_async_allocator_inst; |
| 11588 | 11594 | if (call_instruction->async_allocator == nullptr) { |
| 11589 | | uncasted_async_allocator_inst = ir_get_implicit_allocator(ira, &call_instruction->base, parent_fn_entry); |
| 11595 | uncasted_async_allocator_inst = ir_get_implicit_allocator(ira, &call_instruction->base); |
| 11590 | 11596 | if (type_is_invalid(uncasted_async_allocator_inst->value.type)) |
| 11591 | 11597 | return ira->codegen->builtin_types.entry_invalid; |
| 11592 | 11598 | } else { |
| ... | ... | @@ -16816,6 +16822,11 @@ static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstr |
| 16816 | 16822 | zig_panic("TODO ir_analyze_instruction_coro_begin"); |
| 16817 | 16823 | } |
| 16818 | 16824 | |
| 16825 | static TypeTableEntry *ir_analyze_instruction_get_implicit_allocator(IrAnalyze *ira, IrInstructionGetImplicitAllocator *instruction) { |
| 16826 | IrInstruction *result = ir_get_implicit_allocator(ira, &instruction->base); |
| 16827 | return result->value.type; |
| 16828 | } |
| 16829 | |
| 16819 | 16830 | static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) { |
| 16820 | 16831 | switch (instruction->id) { |
| 16821 | 16832 | case IrInstructionIdInvalid: |
| ... | ... | @@ -16831,7 +16842,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 16831 | 16842 | case IrInstructionIdErrWrapCode: |
| 16832 | 16843 | case IrInstructionIdErrWrapPayload: |
| 16833 | 16844 | case IrInstructionIdCast: |
| 16834 | | case IrInstructionIdGetImplicitAllocator: |
| 16835 | 16845 | zig_unreachable(); |
| 16836 | 16846 | case IrInstructionIdReturn: |
| 16837 | 16847 | return ir_analyze_instruction_return(ira, (IrInstructionReturn *)instruction); |
| ... | ... | @@ -17029,6 +17039,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 17029 | 17039 | return ir_analyze_instruction_coro_size(ira, (IrInstructionCoroSize *)instruction); |
| 17030 | 17040 | case IrInstructionIdCoroBegin: |
| 17031 | 17041 | return ir_analyze_instruction_coro_begin(ira, (IrInstructionCoroBegin *)instruction); |
| 17042 | case IrInstructionIdGetImplicitAllocator: |
| 17043 | return ir_analyze_instruction_get_implicit_allocator(ira, (IrInstructionGetImplicitAllocator *)instruction); |
| 17032 | 17044 | } |
| 17033 | 17045 | zig_unreachable(); |
| 17034 | 17046 | } |