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 {
25692569struct IrInstruction {
25702570 Scope *scope;
25712571 AstNode *source_node;
2572 ConstExprValue value;
2573 size_t debug_id;
25742572 LLVMValueRef llvm_value;
2573 ConstExprValue value;
2574 uint32_t debug_id;
25752575 // if ref_count is zero and the instruction has no side effects,
25762576 // the instruction can be omitted in codegen
2577 size_t ref_count;
2577 uint32_t ref_count;
25782578 // When analyzing IR, instructions that point to this instruction in the "old ir"
25792579 // can find the instruction that corresponds to this value in the "new ir"
25802580 // with this child field.
src/ir.cpp+4-3
......@@ -10822,7 +10822,8 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction
1082210822 IrSuspendPosition *suspend_pos)
1082310823{
1082410824 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,
1082610827 ira->old_irb.current_basic_block->debug_id,
1082710828 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint,
1082810829 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id,
......@@ -10860,7 +10861,7 @@ static IrInstruction *ira_resume(IrAnalyze *ira) {
1086010861 ira->instruction_index = pos.instruction_index;
1086110862 assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length);
1086210863 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,
1086410865 ira->old_irb.current_basic_block->debug_id,
1086510866 ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->debug_id);
1086610867 }
......@@ -26328,7 +26329,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
2632826329 }
2632926330
2633026331 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);
2633226333 }
2633326334 IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
2633426335 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
385385 const char mark = trailing ? ':' : '#';
386386 const char *type_name = instruction->value.type ? buf_ptr(&instruction->value.type->name) : "(unknown)";
387387 const char *ref_count = ir_has_side_effects(instruction) ?
388 "-" : buf_ptr(buf_sprintf("%" ZIG_PRI_usize "", instruction->ref_count));
389 fprintf(irp->f, "%c%-3zu| %-22s| %-12s| %-2s| ", mark, instruction->debug_id,
388 "-" : buf_ptr(buf_sprintf("%" PRIu32 "", instruction->ref_count));
389 fprintf(irp->f, "%c%-3" PRIu32 "| %-22s| %-12s| %-2s| ", mark, instruction->debug_id,
390390 ir_instruction_type_str(instruction->id), type_name, ref_count);
391391}
392392
......@@ -398,7 +398,7 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {
398398}
399399
400400static 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);
402402 if (irp->pass != IrPassSrc && irp->printed.maybe_get(instruction) == nullptr) {
403403 irp->printed.put(instruction, 0);
404404 irp->pending.append(instruction);