authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-09-30 19:59:49+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-09-30 19:59:49+03:00
log82f0ede3ad4150a80ab745419664f1dce4a6be9c
treed939c1a1e4999f70138a4a2e251399d9bca7619b
parentcb5d290f33d28ca3921d5a341be48a6d8099ce57

Added some c_allocator.deallocate calls


4 files changed, 34 insertions(+), 11 deletions(-)

src/stage1/analyze.cpp+2-4
......@@ -3120,12 +3120,9 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
31203120 bool create_enum_type = is_auto_enum || (!is_explicit_enum && want_safety);
31213121 bool *covered_enum_fields;
31223122 bool *is_zero_bits = heap::c_allocator.allocate<bool>(field_count);
3123 ZigLLVMDIEnumerator **di_enumerators;
31243123 if (create_enum_type) {
31253124 occupied_tag_values.init(field_count);
31263125
3127 di_enumerators = heap::c_allocator.allocate<ZigLLVMDIEnumerator*>(field_count);
3128
31293126 ZigType *tag_int_type;
31303127 if (enum_type_node != nullptr) {
31313128 tag_int_type = analyze_type_expr(g, scope, enum_type_node);
......@@ -3269,7 +3266,6 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
32693266 }
32703267
32713268 if (create_enum_type) {
3272 di_enumerators[i] = ZigLLVMCreateDebugEnumerator(g->dbuilder, buf_ptr(union_field->name), i);
32733269 union_field->enum_field = &tag_type->data.enumeration.fields[i];
32743270 union_field->enum_field->name = union_field->name;
32753271 union_field->enum_field->decl_index = i;
......@@ -3336,6 +3332,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
33363332 gen_field_index += 1;
33373333 }
33383334 }
3335 heap::c_allocator.deallocate(is_zero_bits, field_count);
33393336
33403337 bool src_have_tag = is_auto_enum || is_explicit_enum;
33413338
......@@ -3403,6 +3400,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
34033400 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
34043401 }
34053402 }
3403 heap::c_allocator.deallocate(covered_enum_fields, tag_type->data.enumeration.src_field_count);
34063404 }
34073405
34083406 if (union_type->data.unionation.resolve_status == ResolveStatusInvalid) {
src/stage1/codegen.cpp+26-7
......@@ -4414,6 +4414,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
44144414 }
44154415 }
44164416 LLVMTypeRef frame_with_args_type = LLVMStructType(field_types, field_count, false);
4417 heap::c_allocator.deallocate(field_types, field_count);
44174418 LLVMTypeRef ptr_frame_with_args_type = LLVMPointerType(frame_with_args_type, 0);
44184419
44194420 casted_frame = LLVMBuildBitCast(g->builder, frame_result_loc, ptr_frame_with_args_type, "");
......@@ -4825,12 +4826,15 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, I
48254826 ret_type = get_llvm_type(g, instruction->base.value->type);
48264827 }
48274828 LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, (unsigned)input_and_output_count, false);
4829 heap::c_allocator.deallocate(param_types, input_and_output_count);
48284830
48294831 bool is_volatile = instruction->has_side_effects || (asm_expr->output_list.length == 0);
48304832 LLVMValueRef asm_fn = LLVMGetInlineAsm(function_type, buf_ptr(&llvm_template), buf_len(&llvm_template),
48314833 buf_ptr(&constraint_buf), buf_len(&constraint_buf), is_volatile, false, LLVMInlineAsmDialectATT);
48324834
4833 return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");
4835 LLVMValueRef built_call = LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");
4836 heap::c_allocator.deallocate(param_values, input_and_output_count);
4837 return built_call;
48344838}
48354839
48364840static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueRef maybe_handle) {
......@@ -5083,6 +5087,8 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrIns
50835087 incoming_blocks[i] = instruction->incoming_blocks[i]->llvm_exit_block;
50845088 }
50855089 LLVMAddIncoming(phi, incoming_values, incoming_blocks, (unsigned)instruction->incoming_count);
5090 heap::c_allocator.deallocate(incoming_values, instruction->incoming_count);
5091 heap::c_allocator.deallocate(incoming_blocks, instruction->incoming_count);
50865092 return phi;
50875093}
50885094
......@@ -7459,10 +7465,14 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n
74597465 }
74607466 }
74617467 if (make_unnamed_struct) {
7462 return LLVMConstStruct(fields, type_entry->data.structure.gen_field_count,
7468 LLVMValueRef unnamed_struct = LLVMConstStruct(fields, type_entry->data.structure.gen_field_count,
74637469 type_entry->data.structure.layout == ContainerLayoutPacked);
7470 heap::c_allocator.deallocate(fields, type_entry->data.structure.gen_field_count);
7471 return unnamed_struct;
74647472 } else {
7465 return LLVMConstNamedStruct(get_llvm_type(g, type_entry), fields, type_entry->data.structure.gen_field_count);
7473 LLVMValueRef named_struct = LLVMConstNamedStruct(get_llvm_type(g, type_entry), fields, type_entry->data.structure.gen_field_count);
7474 heap::c_allocator.deallocate(fields, type_entry->data.structure.gen_field_count);
7475 return named_struct;
74667476 }
74677477 }
74687478 case ZigTypeIdArray:
......@@ -7487,9 +7497,13 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n
74877497 values[len] = gen_const_val(g, type_entry->data.array.sentinel, "");
74887498 }
74897499 if (make_unnamed_struct) {
7490 return LLVMConstStruct(values, full_len, true);
7500 LLVMValueRef unnamed_struct = LLVMConstStruct(values, full_len, true);
7501 heap::c_allocator.deallocate(values, full_len);
7502 return unnamed_struct;
74917503 } else {
7492 return LLVMConstArray(element_type_ref, values, (unsigned)full_len);
7504 LLVMValueRef array = LLVMConstArray(element_type_ref, values, (unsigned)full_len);
7505 heap::c_allocator.deallocate(values, full_len);
7506 return array;
74937507 }
74947508 }
74957509 case ConstArraySpecialBuf: {
......@@ -7511,7 +7525,9 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n
75117525 ZigValue *elem_value = &const_val->data.x_array.data.s_none.elements[i];
75127526 values[i] = gen_const_val(g, elem_value, "");
75137527 }
7514 return LLVMConstVector(values, len);
7528 LLVMValueRef vector = LLVMConstVector(values, len);
7529 heap::c_allocator.deallocate(values, len);
7530 return vector;
75157531 }
75167532 case ConstArraySpecialBuf: {
75177533 Buf *buf = const_val->data.x_array.data.s_buf;
......@@ -7520,7 +7536,9 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n
75207536 for (uint64_t i = 0; i < len; i += 1) {
75217537 values[i] = LLVMConstInt(g->builtin_types.entry_u8->llvm_type, buf_ptr(buf)[i], false);
75227538 }
7523 return LLVMConstVector(values, len);
7539 LLVMValueRef vector = LLVMConstVector(values, len);
7540 heap::c_allocator.deallocate(values, len);
7541 return vector;
75247542 }
75257543 }
75267544 zig_unreachable();
......@@ -7742,6 +7760,7 @@ static void generate_error_name_table(CodeGen *g) {
77427760 }
77437761
77447762 LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length);
7763 heap::c_allocator.deallocate(values, g->errors_by_index.length);
77457764
77467765 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),
77477766 get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table"))));
src/stage1/ir.cpp+4
......@@ -24144,6 +24144,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc
2414424144 first_non_const_instruction = result_loc;
2414524145 }
2414624146 }
24147 heap::c_allocator.deallocate(field_assign_nodes, actual_field_count);
2414724148 if (any_missing)
2414824149 return ira->codegen->invalid_inst_gen;
2414924150
......@@ -29840,6 +29841,7 @@ static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrIn
2984029841 buf_write_value_bytes(ira->codegen, buf, val);
2984129842 if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value)))
2984229843 return ira->codegen->invalid_inst_gen;
29844 heap::c_allocator.deallocate(buf, src_size_bytes);
2984329845 return result;
2984429846 }
2984529847
......@@ -30877,6 +30879,8 @@ static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBi
3087730879 ira->codegen->is_big_endian,
3087830880 int_type->data.integral.is_signed);
3087930881
30882 heap::c_allocator.deallocate(comptime_buf, buf_size);
30883 heap::c_allocator.deallocate(result_buf, buf_size);
3088030884 return result;
3088130885 }
3088230886
src/stage1/os.cpp+2
......@@ -127,6 +127,7 @@ static void os_spawn_process_posix(ZigList<const char *> &args, Termination *ter
127127 int status;
128128 waitpid(pid, &status, 0);
129129 populate_termination(term, status);
130 heap::c_allocator.deallocate(argv, args.length + 1);
130131}
131132#endif
132133
......@@ -748,6 +749,7 @@ static Buf os_path_resolve_posix(Buf **paths_ptr, size_t paths_len) {
748749
749750 Buf return_value = BUF_INIT;
750751 buf_init_from_mem(&return_value, (char *)result_ptr, result_index);
752 heap::c_allocator.deallocate(result_ptr, result_len);
751753 return return_value;
752754}
753755#endif