authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2019-10-26 13:02:32-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-26 16:45:46-04:00
logb8305b564819dd88ed9422f312160fe0ab777f1b
tree7c8a36e7914a9b20ce559fa533077641b5361043
parentee21bab25391a2b0111720239841e22206ddbd31

Don't save/restore stack on newStackCall to noreturn function


1 files changed, 9 insertions(+), 6 deletions(-)

src/codegen.cpp+9-6
......@@ -4209,15 +4209,19 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
42094209 } else if (instruction->modifier == CallModifierAsync) {
42104210 zig_panic("TODO @asyncCall of non-async function");
42114211 } else {
4212 LLVMValueRef stacksave_fn_val = get_stacksave_fn_val(g);
4213 LLVMValueRef stackrestore_fn_val = get_stackrestore_fn_val(g);
4214
42154212 LLVMValueRef new_stack_addr = get_new_stack_addr(g, ir_llvm_value(g, instruction->new_stack));
4216 LLVMValueRef old_stack_ref = LLVMBuildCall(g->builder, stacksave_fn_val, nullptr, 0, "");
4213 LLVMValueRef old_stack_ref;
4214 if (src_return_type->id != ZigTypeIdUnreachable) {
4215 LLVMValueRef stacksave_fn_val = get_stacksave_fn_val(g);
4216 old_stack_ref = LLVMBuildCall(g->builder, stacksave_fn_val, nullptr, 0, "");
4217 }
42174218 gen_set_stack_pointer(g, new_stack_addr);
42184219 result = ZigLLVMBuildCall(g->builder, fn_val,
42194220 gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, fn_inline, "");
4220 LLVMBuildCall(g->builder, stackrestore_fn_val, &old_stack_ref, 1, "");
4221 if (src_return_type->id != ZigTypeIdUnreachable) {
4222 LLVMValueRef stackrestore_fn_val = get_stackrestore_fn_val(g);
4223 LLVMBuildCall(g->builder, stackrestore_fn_val, &old_stack_ref, 1, "");
4224 }
42214225 }
42224226
42234227 if (src_return_type->id == ZigTypeIdUnreachable) {
......@@ -10409,4 +10413,3 @@ void codegen_switch_sub_prog_node(CodeGen *g, Stage2ProgressNode *node) {
1040910413 }
1041010414 g->sub_progress_node = node;
1041110415}
10412