| ... | @@ -2102,6 +2102,14 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut | ... | @@ -2102,6 +2102,14 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut |
| 2102 | | 2102 | |
| 2103 | static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrInstructionReturn *return_instruction) { | 2103 | static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrInstructionReturn *return_instruction) { |
| 2104 | if (g->cur_fn->resume_blocks.length != 0) { | 2104 | if (g->cur_fn->resume_blocks.length != 0) { |
| | 2105 | if (ir_want_runtime_safety(g, &return_instruction->base)) { |
| | 2106 | LLVMValueRef locals_ptr = g->cur_ret_ptr; |
| | 2107 | LLVMValueRef resume_index_ptr = LLVMBuildStructGEP(g->builder, locals_ptr, coro_resume_index_index, ""); |
| | 2108 | LLVMValueRef new_resume_index = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, |
| | 2109 | g->cur_fn->resume_blocks.length + 2, false); |
| | 2110 | LLVMBuildStore(g->builder, new_resume_index, resume_index_ptr); |
| | 2111 | } |
| | 2112 | |
| 2105 | LLVMBuildRet(g->builder, LLVMGetUndef(g->builtin_types.entry_usize->llvm_type)); | 2113 | LLVMBuildRet(g->builder, LLVMGetUndef(g->builtin_types.entry_usize->llvm_type)); |
| 2106 | return nullptr; | 2114 | return nullptr; |
| 2107 | } | 2115 | } |