authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 13:55:34-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 13:55:34-05:00
log2e6aa6d813cf3fd4180b8c9ffc671b4bcee54586
treea9ada6a05284c7692ac608c78f0fcc20f54588e1
parenta76b048354e5754b18ecd83ad21cf45c5a34e276

IR: fix codegen of ref instruction


2 files changed, 11 insertions(+), 1 deletions(-)

src/codegen.cpp+2
......@@ -2854,6 +2854,8 @@ static void do_code_gen(CodeGen *g) {
28542854 } else if (instruction->id == IrInstructionIdRef) {
28552855 IrInstructionRef *ref_instruction = (IrInstructionRef *)instruction;
28562856 slot = &ref_instruction->tmp_ptr;
2857 assert(instruction->type_entry->id == TypeTableEntryIdPointer);
2858 slot_type = instruction->type_entry->data.pointer.child_type;
28572859 } else if (instruction->id == IrInstructionIdContainerInitList) {
28582860 IrInstructionContainerInitList *container_init_list_instruction = (IrInstructionContainerInitList *)instruction;
28592861 slot = &container_init_list_instruction->tmp_ptr;
src/ir.cpp+9-1
......@@ -4732,7 +4732,15 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
47324732 IrInstructionLoadPtr *load_ptr_inst = (IrInstructionLoadPtr *)value;
47334733 return load_ptr_inst->ptr;
47344734 } else {
4735 zig_panic("TODO more ways to cast to const pointer");
4735 IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instr->scope, source_instr->source_node, value);
4736
4737 TypeTableEntry *child_type = wanted_type->data.pointer.child_type;
4738 if (type_has_bits(child_type)) {
4739 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
4740 assert(fn_entry);
4741 fn_entry->alloca_list.append(new_instruction);
4742 }
4743 return new_instruction;
47364744 }
47374745}
47384746