| author | |
| committer | |
| log | d74b8567cf6a81550831a9ea02f2cebcb4db9846 |
| tree | a6c8a7552c19d479cb6141d50550997a2f1a44b3 |
| parent | 00d82e34df92c181d20064c0c2f80feaba9dab03 |
| signature |
When `@frameSize` is never called, and `@asyncCall` on a runtime-known
pointer is never used, no prefix data for async functions is needed.
Related: #31603 files changed, 8 insertions(+), 1 deletions(-)
src/all_types.hpp+1| ... | ... | @@ -1989,6 +1989,7 @@ struct CodeGen { |
| 1989 | 1989 | bool system_linker_hack; |
| 1990 | 1990 | bool reported_bad_link_libc_error; |
| 1991 | 1991 | bool is_dynamic; // shared library rather than static library. dynamic musl rather than static musl. |
| 1992 | bool need_frame_size_prefix_data; | |
| 1992 | 1993 | |
| 1993 | 1994 | //////////////////////////// Participates in Input Parameter Cache Hash |
| 1994 | 1995 | /////// Note: there is a separate cache hash for builtin.zig, when adding fields, |
src/codegen.cpp+4-1| ... | ... | @@ -3775,6 +3775,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) { |
| 3775 | 3775 | } |
| 3776 | 3776 | |
| 3777 | 3777 | static LLVMValueRef gen_frame_size(CodeGen *g, LLVMValueRef fn_val) { |
| 3778 | assert(g->need_frame_size_prefix_data); | |
| 3778 | 3779 | LLVMTypeRef usize_llvm_type = g->builtin_types.entry_usize->llvm_type; |
| 3779 | 3780 | LLVMTypeRef ptr_usize_llvm_type = LLVMPointerType(usize_llvm_type, 0); |
| 3780 | 3781 | LLVMValueRef casted_fn_val = LLVMBuildBitCast(g->builder, fn_val, ptr_usize_llvm_type, ""); |
| ... | ... | @@ -7208,7 +7209,9 @@ static void do_code_gen(CodeGen *g) { |
| 7208 | 7209 | |
| 7209 | 7210 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| 7210 | 7211 | LLVMValueRef size_val = LLVMConstInt(usize_type_ref, fn_table_entry->frame_type->abi_size, false); |
| 7211 | ZigLLVMFunctionSetPrefixData(fn_table_entry->llvm_value, size_val); | |
| 7212 | if (g->need_frame_size_prefix_data) { | |
| 7213 | ZigLLVMFunctionSetPrefixData(fn_table_entry->llvm_value, size_val); | |
| 7214 | } | |
| 7212 | 7215 | |
| 7213 | 7216 | if (!g->strip_debug_symbols) { |
| 7214 | 7217 | AstNode *source_node = fn_table_entry->proto_node; |
src/ir.cpp+3| ... | ... | @@ -15671,6 +15671,7 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall |
| 15671 | 15671 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 15672 | 15672 | false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false); |
| 15673 | 15673 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 15674 | ira->codegen->need_frame_size_prefix_data = true; | |
| 15674 | 15675 | return ir_implicit_cast(ira, new_stack, u8_slice); |
| 15675 | 15676 | } |
| 15676 | 15677 | } |
| ... | ... | @@ -22533,6 +22534,8 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru |
| 22533 | 22534 | return ira->codegen->invalid_instruction; |
| 22534 | 22535 | } |
| 22535 | 22536 | |
| 22537 | ira->codegen->need_frame_size_prefix_data = true; | |
| 22538 | ||
| 22536 | 22539 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, |
| 22537 | 22540 | instruction->base.source_node, fn); |
| 22538 | 22541 | result->value.type = ira->codegen->builtin_types.entry_usize; |