authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-05 16:06:06-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-05 16:06:06-05:00
log135c021c83c08e1ab42f6d24a98f3b14e53b5b62
tree2d272426b6cd9d933aec7d8e3bafc00e469f2d12
parent025051885be8c99bfccc7d3746ac138f7d5546e1

delete unneeded IR code and fix assigning to const ptr


1 files changed, 1 insertions(+), 28 deletions(-)

src/ir.cpp+1-28
......@@ -9262,7 +9262,7 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
92629262 if (casted_value == ira->codegen->invalid_instruction)
92639263 return ira->codegen->builtin_types.entry_invalid;
92649264
9265 if (ptr->value.special != ConstValSpecialRuntime) {
9265 if (ptr->value.special != ConstValSpecialRuntime && ptr->value.data.x_ptr.special != ConstPtrSpecialRuntime) {
92669266 bool is_inline = (ptr->value.data.x_ptr.special == ConstPtrSpecialInline);
92679267 if (casted_value->value.special != ConstValSpecialRuntime) {
92689268 ConstExprValue *dest_val = const_ptr_pointee(&ptr->value);
......@@ -9278,33 +9278,6 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
92789278 }
92799279 }
92809280
9281 if (ptr->value.special != ConstValSpecialRuntime) {
9282 // This memory location is transforming from known at compile time to known at runtime.
9283 // We must emit our own var ptr instruction.
9284 // TODO can we delete this code now that we have inline var?
9285 ptr->value.special = ConstValSpecialRuntime;
9286 IrInstruction *new_ptr_inst;
9287 if (ptr->id == IrInstructionIdVarPtr) {
9288 IrInstructionVarPtr *var_ptr_inst = (IrInstructionVarPtr *)ptr;
9289 VariableTableEntry *var = var_ptr_inst->var;
9290 new_ptr_inst = ir_build_var_ptr(&ira->new_irb, store_ptr_instruction->base.scope,
9291 store_ptr_instruction->base.source_node, var, false);
9292 assert(var->mem_slot_index != SIZE_MAX);
9293 ConstExprValue *mem_slot = &ira->exec_context.mem_slot_list[var->mem_slot_index];
9294 mem_slot->special = ConstValSpecialRuntime;
9295 } else if (ptr->id == IrInstructionIdFieldPtr) {
9296 zig_panic("TODO");
9297 } else if (ptr->id == IrInstructionIdElemPtr) {
9298 zig_panic("TODO");
9299 } else {
9300 zig_unreachable();
9301 }
9302 new_ptr_inst->value.type = ptr->value.type;
9303 ir_build_store_ptr(&ira->new_irb, store_ptr_instruction->base.scope,
9304 store_ptr_instruction->base.source_node, new_ptr_inst, casted_value);
9305 return ir_analyze_void(ira, &store_ptr_instruction->base);
9306 }
9307
93089281 ir_build_store_ptr_from(&ira->new_irb, &store_ptr_instruction->base, ptr, casted_value);
93099282 return ira->codegen->builtin_types.entry_void;
93109283}