authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-19 03:51:04-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-19 03:51:04-04:00
log4e985123447dba40e282e9663e3ca669d3f9243a
tree7975692d2f2934f19d13a1784db87619c525bcaf
parentfa9f1d23968d3b9fe3ae35ed1306aec0cbcfd908
signaturelock-open Commit is signed but in an unrecognized format.

reduce the size of IrInstruction by 8 bytes on 64 bit targets

This brings the std lib tests down from 3.51 GiB memory usage to 3.41 GiB, by making two fields that were 64 bits 32 bits. This is a small thing; the bigger wins will come from the strategy outlined in the previous commit.

3 files changed, 10 insertions(+), 9 deletions(-)

src/all_types.hpp+3-3
...@@ -2569,12 +2569,12 @@ enum IrInstructionId {...@@ -2569,12 +2569,12 @@ enum IrInstructionId {
2569struct IrInstruction {2569struct IrInstruction {
2570 Scope *scope;2570 Scope *scope;
2571 AstNode *source_node;2571 AstNode *source_node;
2572 ConstExprValue value;
2573 size_t debug_id;
2574 LLVMValueRef llvm_value;2572 LLVMValueRef llvm_value;
2573 ConstExprValue value;
2574 uint32_t debug_id;
2575 // if ref_count is zero and the instruction has no side effects,2575 // if ref_count is zero and the instruction has no side effects,
2576 // the instruction can be omitted in codegen2576 // the instruction can be omitted in codegen
2577 size_t ref_count;2577 uint32_t ref_count;
2578 // When analyzing IR, instructions that point to this instruction in the "old ir"2578 // When analyzing IR, instructions that point to this instruction in the "old ir"
2579 // can find the instruction that corresponds to this value in the "new ir"2579 // can find the instruction that corresponds to this value in the "new ir"
2580 // with this child field.2580 // with this child field.
src/ir.cpp+4-3
...@@ -10822,7 +10822,8 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction...@@ -10822,7 +10822,8 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction
10822 IrSuspendPosition *suspend_pos)10822 IrSuspendPosition *suspend_pos)
10823{10823{
10824 if (ira->codegen->verbose_ir) {10824 if (ira->codegen->verbose_ir) {
10825 fprintf(stderr, "suspend %s_%zu %s_%zu #%zu (%zu,%zu)\n", ira->old_irb.current_basic_block->name_hint,10825 fprintf(stderr, "suspend %s_%zu %s_%zu #%" PRIu32 " (%zu,%zu)\n",
10826 ira->old_irb.current_basic_block->name_hint,
10826 ira->old_irb.current_basic_block->debug_id,10827 ira->old_irb.current_basic_block->debug_id,
10827 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint,10828 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint,
10828 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id,10829 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id,
...@@ -10860,7 +10861,7 @@ static IrInstruction *ira_resume(IrAnalyze *ira) {...@@ -10860,7 +10861,7 @@ static IrInstruction *ira_resume(IrAnalyze *ira) {
10860 ira->instruction_index = pos.instruction_index;10861 ira->instruction_index = pos.instruction_index;
10861 assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length);10862 assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length);
10862 if (ira->codegen->verbose_ir) {10863 if (ira->codegen->verbose_ir) {
10863 fprintf(stderr, "%s_%zu #%zu\n", ira->old_irb.current_basic_block->name_hint,10864 fprintf(stderr, "%s_%zu #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint,
10864 ira->old_irb.current_basic_block->debug_id,10865 ira->old_irb.current_basic_block->debug_id,
10865 ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->debug_id);10866 ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->debug_id);
10866 }10867 }
...@@ -26328,7 +26329,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_...@@ -26328,7 +26329,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
26328 }26329 }
2632926330
26330 if (ira->codegen->verbose_ir) {26331 if (ira->codegen->verbose_ir) {
26331 fprintf(stderr, "analyze #%zu\n", old_instruction->debug_id);26332 fprintf(stderr, "analyze #%" PRIu32 "\n", old_instruction->debug_id);
26332 }26333 }
26333 IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction);26334 IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
26334 if (new_instruction != nullptr) {26335 if (new_instruction != nullptr) {
src/ir_print.cpp+3-3
...@@ -385,8 +385,8 @@ static void ir_print_prefix(IrPrint *irp, IrInstruction *instruction, bool trail...@@ -385,8 +385,8 @@ static void ir_print_prefix(IrPrint *irp, IrInstruction *instruction, bool trail
385 const char mark = trailing ? ':' : '#';385 const char mark = trailing ? ':' : '#';
386 const char *type_name = instruction->value.type ? buf_ptr(&instruction->value.type->name) : "(unknown)";386 const char *type_name = instruction->value.type ? buf_ptr(&instruction->value.type->name) : "(unknown)";
387 const char *ref_count = ir_has_side_effects(instruction) ?387 const char *ref_count = ir_has_side_effects(instruction) ?
388 "-" : buf_ptr(buf_sprintf("%" ZIG_PRI_usize "", instruction->ref_count));388 "-" : buf_ptr(buf_sprintf("%" PRIu32 "", instruction->ref_count));
389 fprintf(irp->f, "%c%-3zu| %-22s| %-12s| %-2s| ", mark, instruction->debug_id,389 fprintf(irp->f, "%c%-3" PRIu32 "| %-22s| %-12s| %-2s| ", mark, instruction->debug_id,
390 ir_instruction_type_str(instruction->id), type_name, ref_count);390 ir_instruction_type_str(instruction->id), type_name, ref_count);
391}391}
392392
...@@ -398,7 +398,7 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {...@@ -398,7 +398,7 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {
398}398}
399399
400static void ir_print_var_instruction(IrPrint *irp, IrInstruction *instruction) {400static void ir_print_var_instruction(IrPrint *irp, IrInstruction *instruction) {
401 fprintf(irp->f, "#%" ZIG_PRI_usize "", instruction->debug_id);401 fprintf(irp->f, "#%" PRIu32 "", instruction->debug_id);
402 if (irp->pass != IrPassSrc && irp->printed.maybe_get(instruction) == nullptr) {402 if (irp->pass != IrPassSrc && irp->printed.maybe_get(instruction) == nullptr) {
403 irp->printed.put(instruction, 0);403 irp->printed.put(instruction, 0);
404 irp->pending.append(instruction);404 irp->pending.append(instruction);