| ... | ... | @@ -4059,6 +4059,8 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV |
| 4059 | 4059 | } |
| 4060 | 4060 | |
| 4061 | 4061 | static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrInstGenCall *instruction) { |
| 4062 | Error err; |
| 4063 | |
| 4062 | 4064 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| 4063 | 4065 | |
| 4064 | 4066 | LLVMValueRef fn_val; |
| ... | ... | @@ -4089,6 +4091,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn |
| 4089 | 4091 | ZigList<ZigType *> gen_param_types = {}; |
| 4090 | 4092 | LLVMValueRef result_loc = instruction->result_loc ? ir_llvm_value(g, instruction->result_loc) : nullptr; |
| 4091 | 4093 | LLVMValueRef zero = LLVMConstNull(usize_type_ref); |
| 4094 | bool need_frame_ptr_ptr_spill = false; |
| 4092 | 4095 | LLVMValueRef frame_result_loc_uncasted = nullptr; |
| 4093 | 4096 | LLVMValueRef frame_result_loc; |
| 4094 | 4097 | LLVMValueRef awaiter_init_val; |
| ... | ... | @@ -4127,14 +4130,17 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn |
| 4127 | 4130 | |
| 4128 | 4131 | LLVMPositionBuilderAtEnd(g->builder, ok_block); |
| 4129 | 4132 | } |
| 4133 | need_frame_ptr_ptr_spill = true; |
| 4130 | 4134 | LLVMValueRef frame_ptr_ptr = LLVMBuildStructGEP(g->builder, frame_slice_ptr, slice_ptr_index, ""); |
| 4131 | 4135 | LLVMValueRef frame_ptr = LLVMBuildLoad(g->builder, frame_ptr_ptr, ""); |
| 4132 | 4136 | if (instruction->fn_entry == nullptr) { |
| 4133 | 4137 | ZigType *anyframe_type = get_any_frame_type(g, src_return_type); |
| 4134 | 4138 | frame_result_loc = LLVMBuildBitCast(g->builder, frame_ptr, get_llvm_type(g, anyframe_type), ""); |
| 4135 | 4139 | } else { |
| 4136 | | ZigType *ptr_frame_type = get_pointer_to_type(g, |
| 4137 | | get_fn_frame_type(g, instruction->fn_entry), false); |
| 4140 | ZigType *frame_type = get_fn_frame_type(g, instruction->fn_entry); |
| 4141 | if ((err = type_resolve(g, frame_type, ResolveStatusLLVMFull))) |
| 4142 | codegen_report_errors_and_exit(g); |
| 4143 | ZigType *ptr_frame_type = get_pointer_to_type(g, frame_type, false); |
| 4138 | 4144 | frame_result_loc = LLVMBuildBitCast(g->builder, frame_ptr, |
| 4139 | 4145 | get_llvm_type(g, ptr_frame_type), ""); |
| 4140 | 4146 | } |
| ... | ... | @@ -4405,6 +4411,11 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn |
| 4405 | 4411 | } |
| 4406 | 4412 | } |
| 4407 | 4413 | |
| 4414 | if (need_frame_ptr_ptr_spill) { |
| 4415 | LLVMValueRef frame_slice_ptr = ir_llvm_value(g, instruction->new_stack); |
| 4416 | LLVMValueRef frame_ptr_ptr = LLVMBuildStructGEP(g->builder, frame_slice_ptr, slice_ptr_index, ""); |
| 4417 | frame_result_loc_uncasted = LLVMBuildLoad(g->builder, frame_ptr_ptr, ""); |
| 4418 | } |
| 4408 | 4419 | if (frame_result_loc_uncasted != nullptr && instruction->fn_entry != nullptr) { |
| 4409 | 4420 | // Instead of a spill, we do the bitcast again. The uncasted LLVM IR instruction will |
| 4410 | 4421 | // be an Alloca from the entry block, so it does not need to be spilled. |