| ... | ... | @@ -17942,8 +17942,6 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17942 | 17942 | return ir_implicit_cast(ira, var->ptr_instruction, var_ptr_type); |
| 17943 | 17943 | } |
| 17944 | 17944 | |
| 17945 | | ZigValue *mem_slot = nullptr; |
| 17946 | | |
| 17947 | 17945 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| 17948 | 17946 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| 17949 | 17947 | |
| ... | ... | @@ -17951,17 +17949,11 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17951 | 17949 | instruction->scope, instruction->source_node, var); |
| 17952 | 17950 | result->value->type = var_ptr_type; |
| 17953 | 17951 | |
| 17954 | | if (linkage_makes_it_runtime || var->is_thread_local) |
| 17955 | | goto no_mem_slot; |
| 17956 | | |
| 17957 | | if (value_is_comptime(var->const_value)) { |
| 17958 | | mem_slot = var->const_value; |
| 17959 | | } |
| 17960 | | |
| 17961 | | if (mem_slot != nullptr) { |
| 17962 | | switch (mem_slot->special) { |
| 17952 | if (!linkage_makes_it_runtime && !var->is_thread_local && value_is_comptime(var->const_value)) { |
| 17953 | ZigValue *val = var->const_value; |
| 17954 | switch (val->special) { |
| 17963 | 17955 | case ConstValSpecialRuntime: |
| 17964 | | goto no_mem_slot; |
| 17956 | break; |
| 17965 | 17957 | case ConstValSpecialStatic: // fallthrough |
| 17966 | 17958 | case ConstValSpecialLazy: // fallthrough |
| 17967 | 17959 | case ConstValSpecialUndef: { |
| ... | ... | @@ -17977,15 +17969,12 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17977 | 17969 | result->value->special = ConstValSpecialStatic; |
| 17978 | 17970 | result->value->data.x_ptr.mut = ptr_mut; |
| 17979 | 17971 | result->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 17980 | | result->value->data.x_ptr.data.ref.pointee = mem_slot; |
| 17972 | result->value->data.x_ptr.data.ref.pointee = val; |
| 17981 | 17973 | return result; |
| 17982 | 17974 | } |
| 17983 | 17975 | } |
| 17984 | | zig_unreachable(); |
| 17985 | 17976 | } |
| 17986 | 17977 | |
| 17987 | | no_mem_slot: |
| 17988 | | |
| 17989 | 17978 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); |
| 17990 | 17979 | result->value->data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; |
| 17991 | 17980 | |
| ... | ... | @@ -19699,9 +19688,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19699 | 19688 | return_type = adjust_ptr_align(ira->codegen, return_type, chosen_align); |
| 19700 | 19689 | } |
| 19701 | 19690 | |
| 19691 | // TODO The `array_type->id == ZigTypeIdArray` exception here should not be an exception; |
| 19692 | // the `orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar` clause should be omitted completely. |
| 19693 | // However there are bugs to fix before this improvement can be made. |
| 19702 | 19694 | if (orig_array_ptr_val->special != ConstValSpecialRuntime && |
| 19703 | 19695 | orig_array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 19704 | | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar)) |
| 19696 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || array_type->id == ZigTypeIdArray)) |
| 19705 | 19697 | { |
| 19706 | 19698 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 19707 | 19699 | elem_ptr_instruction->base.source_node); |