mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
IR: fix codegen of ref instruction
This commit is contained in:
parent
a76b048354
commit
2e6aa6d813
@ -2854,6 +2854,8 @@ static void do_code_gen(CodeGen *g) {
|
||||
} else if (instruction->id == IrInstructionIdRef) {
|
||||
IrInstructionRef *ref_instruction = (IrInstructionRef *)instruction;
|
||||
slot = &ref_instruction->tmp_ptr;
|
||||
assert(instruction->type_entry->id == TypeTableEntryIdPointer);
|
||||
slot_type = instruction->type_entry->data.pointer.child_type;
|
||||
} else if (instruction->id == IrInstructionIdContainerInitList) {
|
||||
IrInstructionContainerInitList *container_init_list_instruction = (IrInstructionContainerInitList *)instruction;
|
||||
slot = &container_init_list_instruction->tmp_ptr;
|
||||
|
||||
10
src/ir.cpp
10
src/ir.cpp
@ -4732,7 +4732,15 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
|
||||
IrInstructionLoadPtr *load_ptr_inst = (IrInstructionLoadPtr *)value;
|
||||
return load_ptr_inst->ptr;
|
||||
} else {
|
||||
zig_panic("TODO more ways to cast to const pointer");
|
||||
IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instr->scope, source_instr->source_node, value);
|
||||
|
||||
TypeTableEntry *child_type = wanted_type->data.pointer.child_type;
|
||||
if (type_has_bits(child_type)) {
|
||||
FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
|
||||
assert(fn_entry);
|
||||
fn_entry->alloca_list.append(new_instruction);
|
||||
}
|
||||
return new_instruction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user