@@ -7748,8 +7748,9 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
77487748static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *type_entry) {
77497749 if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) {
77507750 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
7751- assert(fn_entry);
7752- fn_entry->alloca_list.append(instruction);
7751+ if (fn_entry != nullptr) {
7752+ fn_entry->alloca_list.append(instruction);
7753+ }
77537754 }
77547755}
77557756
@@ -7851,9 +7852,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
78517852 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op);
78527853 result->value.type = wanted_type;
78537854 if (need_alloca) {
7854- FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
7855- if (fn_entry)
7856- fn_entry->alloca_list.append(result);
7855+ ir_add_alloca(ira, result, wanted_type);
78577856 }
78587857 return result;
78597858 }
@@ -8287,6 +8286,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
82878286 assert(fn_entry);
82888287 fn_entry->alloca_list.append(new_instruction);
82898288 }
8289+ ir_add_alloca(ira, new_instruction, child_type);
82908290 return new_instruction;
82918291 }
82928292}
@@ -8330,13 +8330,15 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
83308330
83318331 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,
83328332 is_const, is_volatile, get_abi_alignment(ira->codegen, value->value.type), 0, 0);
8333- FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
8334- assert(fn_entry);
83358333 IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instruction->scope,
83368334 source_instruction->source_node, value, is_const, is_volatile);
83378335 new_instruction->value.type = ptr_type;
83388336 new_instruction->value.data.rh_ptr = RuntimeHintPtrStack;
8339- fn_entry->alloca_list.append(new_instruction);
8337+ if (type_has_bits(ptr_type)) {
8338+ FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
8339+ assert(fn_entry);
8340+ fn_entry->alloca_list.append(new_instruction);
8341+ }
83408342 return new_instruction;
83418343}
83428344
0 commit comments