| ... | ... | @@ -10351,30 +10351,40 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 10351 | 10351 | |
| 10352 | 10352 | bool is_const = (var->value->type->id == TypeTableEntryIdMetaType) ? is_const_ptr : var->src_is_const; |
| 10353 | 10353 | bool is_volatile = (var->value->type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false; |
| 10354 | | if (mem_slot && mem_slot->special != ConstValSpecialRuntime) { |
| 10355 | | ConstPtrMut ptr_mut; |
| 10356 | | if (comptime_var_mem) { |
| 10357 | | ptr_mut = ConstPtrMutComptimeVar; |
| 10358 | | } else if (var->gen_is_const) { |
| 10359 | | ptr_mut = ConstPtrMutComptimeConst; |
| 10360 | | } else { |
| 10361 | | assert(!comptime_var_mem); |
| 10362 | | ptr_mut = ConstPtrMutRuntimeVar; |
| 10354 | if (mem_slot != nullptr) { |
| 10355 | switch (mem_slot->special) { |
| 10356 | case ConstValSpecialRuntime: |
| 10357 | goto no_mem_slot; |
| 10358 | case ConstValSpecialStatic: // fallthrough |
| 10359 | case ConstValSpecialUndef: { |
| 10360 | ConstPtrMut ptr_mut; |
| 10361 | if (comptime_var_mem) { |
| 10362 | ptr_mut = ConstPtrMutComptimeVar; |
| 10363 | } else if (var->gen_is_const) { |
| 10364 | ptr_mut = ConstPtrMutComptimeConst; |
| 10365 | } else { |
| 10366 | assert(!comptime_var_mem); |
| 10367 | ptr_mut = ConstPtrMutRuntimeVar; |
| 10368 | } |
| 10369 | return ir_get_const_ptr(ira, instruction, mem_slot, var->value->type, |
| 10370 | ptr_mut, is_const, is_volatile, var->align_bytes); |
| 10371 | } |
| 10363 | 10372 | } |
| 10364 | | return ir_get_const_ptr(ira, instruction, mem_slot, var->value->type, |
| 10365 | | ptr_mut, is_const, is_volatile, var->align_bytes); |
| 10366 | | } else { |
| 10367 | | IrInstruction *var_ptr_instruction = ir_build_var_ptr(&ira->new_irb, |
| 10368 | | instruction->scope, instruction->source_node, var, is_const, is_volatile); |
| 10369 | | var_ptr_instruction->value.type = get_pointer_to_type_extra(ira->codegen, var->value->type, |
| 10370 | | var->src_is_const, is_volatile, var->align_bytes, 0, 0); |
| 10371 | | type_ensure_zero_bits_known(ira->codegen, var->value->type); |
| 10373 | zig_unreachable(); |
| 10374 | } |
| 10372 | 10375 | |
| 10373 | | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); |
| 10374 | | var_ptr_instruction->value.data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; |
| 10376 | no_mem_slot: |
| 10375 | 10377 | |
| 10376 | | return var_ptr_instruction; |
| 10377 | | } |
| 10378 | IrInstruction *var_ptr_instruction = ir_build_var_ptr(&ira->new_irb, |
| 10379 | instruction->scope, instruction->source_node, var, is_const, is_volatile); |
| 10380 | var_ptr_instruction->value.type = get_pointer_to_type_extra(ira->codegen, var->value->type, |
| 10381 | var->src_is_const, is_volatile, var->align_bytes, 0, 0); |
| 10382 | type_ensure_zero_bits_known(ira->codegen, var->value->type); |
| 10383 | |
| 10384 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); |
| 10385 | var_ptr_instruction->value.data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; |
| 10386 | |
| 10387 | return var_ptr_instruction; |
| 10378 | 10388 | } |
| 10379 | 10389 | |
| 10380 | 10390 | static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction, |