| ... | ... | @@ -4146,11 +4146,24 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutable *executable |
| 4146 | 4146 | return LLVMBuildCall(g->builder, get_frame_address_fn_val(g), &zero, 1, ""); |
| 4147 | 4147 | } |
| 4148 | 4148 | |
| 4149 | static LLVMValueRef get_handle_fn_val(CodeGen *g) { |
| 4150 | if (g->coro_frame_fn_val) |
| 4151 | return g->coro_frame_fn_val; |
| 4152 | |
| 4153 | LLVMTypeRef fn_type = LLVMFunctionType( LLVMPointerType(LLVMInt8Type(), 0) |
| 4154 | , nullptr, 0, false); |
| 4155 | Buf *name = buf_sprintf("llvm.coro.frame"); |
| 4156 | g->coro_frame_fn_val = LLVMAddFunction(g->module, buf_ptr(name), fn_type); |
| 4157 | assert(LLVMGetIntrinsicID(g->coro_frame_fn_val)); |
| 4158 | |
| 4159 | return g->coro_frame_fn_val; |
| 4160 | } |
| 4161 | |
| 4149 | 4162 | static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable, |
| 4150 | 4163 | IrInstructionHandle *instruction) |
| 4151 | 4164 | { |
| 4152 | | LLVMValueRef ptr = ir_llvm_value(g, executable->fn_entry->ir_executable.coro_handle->other); |
| 4153 | | return LLVMBuildBitCast(g->builder, ptr, g->builtin_types.entry_promise->type_ref, ""); |
| 4165 | LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_promise->type_ref); |
| 4166 | return LLVMBuildCall(g->builder, get_handle_fn_val(g), &zero, 0, ""); |
| 4154 | 4167 | } |
| 4155 | 4168 | |
| 4156 | 4169 | static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) { |