authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-04 12:50:02-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-04 12:50:02-04:00
log36828a2e6aa6879641bf6980379dd806b6f479a1
tree9d832e1ca40fc4f4d6b9ef9ce0e4ca43e8ff38f3
parentff4591f0e61266da6cac47644986d381b99dec5b
signaturelock-open Commit is signed but in an unrecognized format.

fix incorrect variable ref count

regression introduced by e82cd53df483a

2 files changed, 4 insertions(+), 5 deletions(-)

src/all_types.hpp-1
...@@ -1806,7 +1806,6 @@ struct VariableTableEntry {...@@ -1806,7 +1806,6 @@ struct VariableTableEntry {
1806 IrExecutable *owner_exec;1806 IrExecutable *owner_exec;
1807 size_t ref_count;1807 size_t ref_count;
1808 VarLinkage linkage;1808 VarLinkage linkage;
1809 IrInstruction *decl_instruction;
1810 uint32_t align_bytes;1809 uint32_t align_bytes;
18111810
1812 // In an inline loop, multiple variables may be created,1811 // In an inline loop, multiple variables may be created,
src/ir.cpp+4-4
...@@ -1446,8 +1446,6 @@ static IrInstruction *ir_build_var_decl(IrBuilder *irb, Scope *scope, AstNode *s...@@ -1446,8 +1446,6 @@ static IrInstruction *ir_build_var_decl(IrBuilder *irb, Scope *scope, AstNode *s
1446 if (align_value) ir_ref_instruction(align_value, irb->current_basic_block);1446 if (align_value) ir_ref_instruction(align_value, irb->current_basic_block);
1447 ir_ref_instruction(init_value, irb->current_basic_block);1447 ir_ref_instruction(init_value, irb->current_basic_block);
14481448
1449 var->decl_instruction = &decl_var_instruction->base;
1450
1451 return &decl_var_instruction->base;1449 return &decl_var_instruction->base;
1452}1450}
14531451
...@@ -12433,8 +12431,6 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12433,8 +12431,6 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
12433 return var->value->type;12431 return var->value->type;
12434 }12432 }
1243512433
12436 var->ref_count = 0;
12437
12438 TypeTableEntry *explicit_type = nullptr;12434 TypeTableEntry *explicit_type = nullptr;
12439 IrInstruction *var_type = nullptr;12435 IrInstruction *var_type = nullptr;
12440 if (decl_var_instruction->var_type != nullptr) {12436 if (decl_var_instruction->var_type != nullptr) {
...@@ -12503,6 +12499,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12503,6 +12499,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
12503 VariableTableEntry *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope,12499 VariableTableEntry *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope,
12504 &var->name, var->src_is_const, var->gen_is_const, var->shadowable, var->is_comptime, true);12500 &var->name, var->src_is_const, var->gen_is_const, var->shadowable, var->is_comptime, true);
12505 new_var->owner_exec = var->owner_exec;12501 new_var->owner_exec = var->owner_exec;
12502 new_var->align_bytes = var->align_bytes;
12506 if (var->mem_slot_index != SIZE_MAX) {12503 if (var->mem_slot_index != SIZE_MAX) {
12507 ConstExprValue *vals = create_const_vals(1);12504 ConstExprValue *vals = create_const_vals(1);
12508 new_var->mem_slot_index = ira->exec_context.mem_slot_list.length;12505 new_var->mem_slot_index = ira->exec_context.mem_slot_list.length;
...@@ -12513,6 +12510,9 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12513,6 +12510,9 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
12513 var = new_var;12510 var = new_var;
12514 }12511 }
1251512512
12513 // This must be done after possibly creating a new variable above
12514 var->ref_count = 0;
12515
12516 var->value->type = result_type;12516 var->value->type = result_type;
12517 assert(var->value->type);12517 assert(var->value->type);
1251812518