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 {
18061806 IrExecutable *owner_exec;
18071807 size_t ref_count;
18081808 VarLinkage linkage;
1809 IrInstruction *decl_instruction;
18101809 uint32_t align_bytes;
18111810
18121811 // 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
14461446 if (align_value) ir_ref_instruction(align_value, irb->current_basic_block);
14471447 ir_ref_instruction(init_value, irb->current_basic_block);
14481448
1449 var->decl_instruction = &decl_var_instruction->base;
1450
14511449 return &decl_var_instruction->base;
14521450}
14531451
......@@ -12433,8 +12431,6 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
1243312431 return var->value->type;
1243412432 }
1243512433
12436 var->ref_count = 0;
12437
1243812434 TypeTableEntry *explicit_type = nullptr;
1243912435 IrInstruction *var_type = nullptr;
1244012436 if (decl_var_instruction->var_type != nullptr) {
......@@ -12503,6 +12499,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
1250312499 VariableTableEntry *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope,
1250412500 &var->name, var->src_is_const, var->gen_is_const, var->shadowable, var->is_comptime, true);
1250512501 new_var->owner_exec = var->owner_exec;
12502 new_var->align_bytes = var->align_bytes;
1250612503 if (var->mem_slot_index != SIZE_MAX) {
1250712504 ConstExprValue *vals = create_const_vals(1);
1250812505 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
1251312510 var = new_var;
1251412511 }
1251512512
12513 // This must be done after possibly creating a new variable above
12514 var->ref_count = 0;
12515
1251612516 var->value->type = result_type;
1251712517 assert(var->value->type);
1251812518