authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-17 21:39:59-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-17 21:55:14-04:00
loge5a0414b05134bfebba4fba097ae882ee0cf36cf
treeacac42272d6be5fbd3d27c9ab6efcce817efc86a
parent4e182c7e9e44a97fe925344057b7b30c3ff2cae4
signature Commit is signed but in an unrecognized format.

misc fixes


2 files changed, 124 insertions(+), 85 deletions(-)

src/all_types.hpp+1-1
...@@ -2544,8 +2544,8 @@ struct IrInstructionElemPtr {...@@ -2544,8 +2544,8 @@ struct IrInstructionElemPtr {
25442544
2545 IrInstruction *array_ptr;2545 IrInstruction *array_ptr;
2546 IrInstruction *elem_index;2546 IrInstruction *elem_index;
2547 IrInstruction *init_array_type;
2547 PtrLen ptr_len;2548 PtrLen ptr_len;
2548 bool initializing;
2549 bool safety_check_on;2549 bool safety_check_on;
2550};2550};
25512551
src/ir.cpp+123-84
...@@ -189,7 +189,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_...@@ -189,7 +189,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_
189static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr,189static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr,
190 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value);190 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value);
191static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,191static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,
192 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value);192 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime);
193static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr,193static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr,
194 IrInstruction *base_ptr, bool safety_check_on, bool initializing);194 IrInstruction *base_ptr, bool safety_check_on, bool initializing);
195static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr,195static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr,
...@@ -261,6 +261,15 @@ static bool is_opt_err_set(ZigType *ty) {...@@ -261,6 +261,15 @@ static bool is_opt_err_set(ZigType *ty) {
261 (ty->id == ZigTypeIdOptional && ty->data.maybe.child_type->id == ZigTypeIdErrorSet);261 (ty->id == ZigTypeIdOptional && ty->data.maybe.child_type->id == ZigTypeIdErrorSet);
262}262}
263263
264static bool is_slice(ZigType *type) {
265 return type->id == ZigTypeIdStruct && type->data.structure.is_slice;
266}
267
268static bool slice_is_const(ZigType *type) {
269 assert(is_slice(type));
270 return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
271}
272
264// This function returns true when you can change the type of a ConstExprValue and the273// This function returns true when you can change the type of a ConstExprValue and the
265// value remains meaningful.274// value remains meaningful.
266static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {275static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {
...@@ -297,8 +306,9 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {...@@ -297,8 +306,9 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {
297 return a->data.floating.bit_count == b->data.floating.bit_count;306 return a->data.floating.bit_count == b->data.floating.bit_count;
298 case ZigTypeIdInt:307 case ZigTypeIdInt:
299 return a->data.integral.is_signed == b->data.integral.is_signed;308 return a->data.integral.is_signed == b->data.integral.is_signed;
300 case ZigTypeIdArray:
301 case ZigTypeIdStruct:309 case ZigTypeIdStruct:
310 return is_slice(a) && is_slice(b);
311 case ZigTypeIdArray:
302 case ZigTypeIdOptional:312 case ZigTypeIdOptional:
303 case ZigTypeIdErrorUnion:313 case ZigTypeIdErrorUnion:
304 case ZigTypeIdEnum:314 case ZigTypeIdEnum:
...@@ -1317,17 +1327,18 @@ static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_...@@ -1317,17 +1327,18 @@ static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_
13171327
1318static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node,1328static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node,
1319 IrInstruction *array_ptr, IrInstruction *elem_index, bool safety_check_on, PtrLen ptr_len,1329 IrInstruction *array_ptr, IrInstruction *elem_index, bool safety_check_on, PtrLen ptr_len,
1320 bool initializing)1330 IrInstruction *init_array_type)
1321{1331{
1322 IrInstructionElemPtr *instruction = ir_build_instruction<IrInstructionElemPtr>(irb, scope, source_node);1332 IrInstructionElemPtr *instruction = ir_build_instruction<IrInstructionElemPtr>(irb, scope, source_node);
1323 instruction->array_ptr = array_ptr;1333 instruction->array_ptr = array_ptr;
1324 instruction->elem_index = elem_index;1334 instruction->elem_index = elem_index;
1325 instruction->safety_check_on = safety_check_on;1335 instruction->safety_check_on = safety_check_on;
1326 instruction->ptr_len = ptr_len;1336 instruction->ptr_len = ptr_len;
1327 instruction->initializing = initializing;1337 instruction->init_array_type = init_array_type;
13281338
1329 ir_ref_instruction(array_ptr, irb->current_basic_block);1339 ir_ref_instruction(array_ptr, irb->current_basic_block);
1330 ir_ref_instruction(elem_index, irb->current_basic_block);1340 ir_ref_instruction(elem_index, irb->current_basic_block);
1341 if (init_array_type != nullptr) ir_ref_instruction(init_array_type, irb->current_basic_block);
13311342
1332 return &instruction->base;1343 return &instruction->base;
1333}1344}
...@@ -4269,7 +4280,7 @@ static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode...@@ -4269,7 +4280,7 @@ static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode
4269 return subscript_instruction;4280 return subscript_instruction;
42704281
4271 IrInstruction *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction,4282 IrInstruction *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction,
4272 subscript_instruction, true, PtrLenSingle, false);4283 subscript_instruction, true, PtrLenSingle, nullptr);
4273 if (lval == LValPtr)4284 if (lval == LValPtr)
4274 return ptr_instruction;4285 return ptr_instruction;
42754286
...@@ -5809,7 +5820,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5809,7 +5820,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
58095820
5810 IrInstruction *elem_index = ir_build_const_usize(irb, scope, expr_node, i);5821 IrInstruction *elem_index = ir_build_const_usize(irb, scope, expr_node, i);
5811 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, elem_index,5822 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, elem_index,
5812 false, PtrLenSingle, true);5823 false, PtrLenSingle, container_type);
5813 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);5824 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);
5814 result_loc_inst->base.id = ResultLocIdInstruction;5825 result_loc_inst->base.id = ResultLocIdInstruction;
5815 result_loc_inst->base.source_instruction = elem_ptr;5826 result_loc_inst->base.source_instruction = elem_ptr;
...@@ -6313,7 +6324,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6313,7 +6324,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
63136324
6314 ir_set_cursor_at_end_and_append_block(irb, body_block);6325 ir_set_cursor_at_end_and_append_block(irb, body_block);
6315 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, parent_scope, node, array_val_ptr, index_val, false,6326 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, parent_scope, node, array_val_ptr, index_val, false,
6316 PtrLenSingle, false);6327 PtrLenSingle, nullptr);
6317 // TODO make it an error to write to element variable or i variable.6328 // TODO make it an error to write to element variable or i variable.
6318 Buf *elem_var_name = elem_node->data.symbol_expr.symbol;6329 Buf *elem_var_name = elem_node->data.symbol_expr.symbol;
6319 ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime);6330 ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime);
...@@ -9614,15 +9625,6 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc...@@ -9614,15 +9625,6 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
9614 return false;9625 return false;
9615}9626}
96169627
9617static bool is_slice(ZigType *type) {
9618 return type->id == ZigTypeIdStruct && type->data.structure.is_slice;
9619}
9620
9621static bool slice_is_const(ZigType *type) {
9622 assert(is_slice(type));
9623 return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
9624}
9625
9626static bool is_tagged_union(ZigType *type) {9628static bool is_tagged_union(ZigType *type) {
9627 if (type->id != ZigTypeIdUnion)9629 if (type->id != ZigTypeIdUnion)
9628 return false;9630 return false;
...@@ -10831,7 +10833,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc...@@ -10831,7 +10833,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
10831 }10833 }
1083210834
10833 if (result_loc == nullptr) result_loc = no_result_loc();10835 if (result_loc == nullptr) result_loc = no_result_loc();
10834 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr);10836 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true);
10835 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {10837 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
10836 return result_loc_inst;10838 return result_loc_inst;
10837 }10839 }
...@@ -11265,7 +11267,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so...@@ -11265,7 +11267,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
11265 }11267 }
1126611268
11267 if (result_loc == nullptr) result_loc = no_result_loc();11269 if (result_loc == nullptr) result_loc = no_result_loc();
11268 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr);11270 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true);
11269 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {11271 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11270 return result_loc_inst;11272 return result_loc_inst;
11271 }11273 }
...@@ -11307,7 +11309,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction...@@ -11307,7 +11309,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
11307 IrInstruction *result_loc_inst;11309 IrInstruction *result_loc_inst;
11308 if (handle_is_ptr(wanted_type)) {11310 if (handle_is_ptr(wanted_type)) {
11309 if (result_loc == nullptr) result_loc = no_result_loc();11311 if (result_loc == nullptr) result_loc = no_result_loc();
11310 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr);11312 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true);
11311 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {11313 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11312 return result_loc_inst;11314 return result_loc_inst;
11313 }11315 }
...@@ -11392,7 +11394,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so...@@ -11392,7 +11394,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
11392 IrInstruction *result_loc_inst;11394 IrInstruction *result_loc_inst;
11393 if (handle_is_ptr(wanted_type)) {11395 if (handle_is_ptr(wanted_type)) {
11394 if (result_loc == nullptr) result_loc = no_result_loc();11396 if (result_loc == nullptr) result_loc = no_result_loc();
11395 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr);11397 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true);
11396 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {11398 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11397 return result_loc_inst;11399 return result_loc_inst;
11398 }11400 }
...@@ -11465,7 +11467,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi...@@ -11465,7 +11467,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
1146511467
11466 IrInstruction *result_loc;11468 IrInstruction *result_loc;
11467 if (type_has_bits(ptr_type) && !handle_is_ptr(value->value.type)) {11469 if (type_has_bits(ptr_type) && !handle_is_ptr(value->value.type)) {
11468 result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value.type, nullptr);11470 result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value.type, nullptr, true);
11469 } else {11471 } else {
11470 result_loc = nullptr;11472 result_loc = nullptr;
11471 }11473 }
...@@ -11509,7 +11511,7 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s...@@ -11509,7 +11511,7 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
11509 if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false);11511 if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false);
1151011512
11511 if (result_loc == nullptr) result_loc = no_result_loc();11513 if (result_loc == nullptr) result_loc = no_result_loc();
11512 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr);11514 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true);
11513 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {11515 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11514 return result_loc_inst;11516 return result_loc_inst;
11515 }11517 }
...@@ -12162,7 +12164,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *...@@ -12162,7 +12164,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
12162 result->value.type = array_type;12164 result->value.type = array_type;
12163 return result;12165 return result;
12164 }12166 }
12165 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr);12167 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, true);
12166 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {12168 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
12167 return result_loc_inst;12169 return result_loc_inst;
12168 }12170 }
...@@ -12743,7 +12745,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc...@@ -12743,7 +12745,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
12743 IrInstruction *result_loc_inst;12745 IrInstruction *result_loc_inst;
12744 if (type_entry->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) {12746 if (type_entry->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) {
12745 if (result_loc == nullptr) result_loc = no_result_loc();12747 if (result_loc == nullptr) result_loc = no_result_loc();
12746 result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr);12748 result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, true);
12747 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {12749 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
12748 return result_loc_inst;12750 return result_loc_inst;
12749 }12751 }
...@@ -14923,7 +14925,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -14923,7 +14925,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
14923 return ira->codegen->invalid_instruction;14925 return ira->codegen->invalid_instruction;
14924 }14926 }
14925 IrInstruction *alloca_gen;14927 IrInstruction *alloca_gen;
14926 if (is_comptime) {14928 if (is_comptime && value != nullptr) {
14927 if (align > value->value.global_refs->align) {14929 if (align > value->value.global_refs->align) {
14928 value->value.global_refs->align = align;14930 value->value.global_refs->align = align;
14929 }14931 }
...@@ -14978,12 +14980,14 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -14978,12 +14980,14 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
14978 }14980 }
1497914981
14980 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,14982 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
14981 peer_parent->resolved_type, nullptr);14983 peer_parent->resolved_type, nullptr, false);
14982 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||14984 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
14983 parent_result_loc->value.type->id == ZigTypeIdUnreachable)14985 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
14984 {14986 {
14985 return parent_result_loc;14987 return parent_result_loc;
14986 }14988 }
14989 // because is_comptime is false, we mark this a runtime pointer
14990 parent_result_loc->value.data.x_ptr.mut = ConstPtrMutRuntimeVar;
14987 result_loc->written = true;14991 result_loc->written = true;
14988 result_loc->resolved_loc = parent_result_loc;14992 result_loc->resolved_loc = parent_result_loc;
14989 return result_loc->resolved_loc;14993 return result_loc->resolved_loc;
...@@ -15026,7 +15030,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -15026,7 +15030,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
15026 }15030 }
1502715031
15028 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent,15032 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent,
15029 dest_type, bitcasted_value);15033 dest_type, bitcasted_value, false);
15030 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||15034 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
15031 parent_result_loc->value.type->id == ZigTypeIdUnreachable)15035 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
15032 {15036 {
...@@ -15054,12 +15058,17 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -15054,12 +15058,17 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
15054}15058}
1505515059
15056static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,15060static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,
15057 ResultLoc *result_loc_pass1, ZigType *value_type, IrInstruction *value)15061 ResultLoc *result_loc_pass1, ZigType *value_type, IrInstruction *value, bool force_runtime)
15058{15062{
15059 IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type,15063 IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type,
15060 value);15064 value);
15061 if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value.type)))15065 if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value.type)))
15062 return result_loc;15066 return result_loc;
15067
15068 if (force_runtime && result_loc_pass1->written && result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
15069 result_loc->value.special = ConstValSpecialRuntime;
15070 }
15071
15063 ir_assert(result_loc->value.type->id == ZigTypeIdPointer, suspend_source_instr);15072 ir_assert(result_loc->value.type->id == ZigTypeIdPointer, suspend_source_instr);
15064 ZigType *actual_elem_type = result_loc->value.type->data.pointer.child_type;15073 ZigType *actual_elem_type = result_loc->value.type->data.pointer.child_type;
15065 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&15074 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
...@@ -15099,10 +15108,20 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrIn...@@ -15099,10 +15108,20 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrIn
15099 ZigType *implicit_elem_type = ir_resolve_type(ira, instruction->ty->child);15108 ZigType *implicit_elem_type = ir_resolve_type(ira, instruction->ty->child);
15100 if (type_is_invalid(implicit_elem_type))15109 if (type_is_invalid(implicit_elem_type))
15101 return ira->codegen->invalid_instruction;15110 return ira->codegen->invalid_instruction;
15102 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, implicit_elem_type, nullptr);15111 ResultLoc *old_result_loc = instruction->result_loc;
15103 if (result_loc != nullptr)15112 for (;;) {
15104 return result_loc;15113 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, old_result_loc,
15105 zig_panic("TODO");15114 implicit_elem_type, nullptr, false);
15115 if (result_loc != nullptr)
15116 return result_loc;
15117
15118 if (instruction->result_loc->id == ResultLocIdPeer) {
15119 old_result_loc = reinterpret_cast<ResultLocPeer *>(instruction->result_loc)->parent->parent;
15120 continue;
15121 }
15122 ir_assert(false, &instruction->base); // TODO
15123 zig_unreachable();
15124 }
15106}15125}
1510715126
15108static void ir_reset_result(ResultLoc *result_loc) {15127static void ir_reset_result(ResultLoc *result_loc) {
...@@ -15484,13 +15503,6 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source...@@ -15484,13 +15503,6 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
15484 return result;15503 return result;
15485}15504}
1548615505
15487static void mark_inferred_ptr_runtime(IrInstruction *ptr) {
15488 ir_assert(ptr->value.type->id == ZigTypeIdPointer, ptr);
15489 if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) {
15490 ptr->value.special = ConstValSpecialRuntime;
15491 }
15492}
15493
15494static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction,15506static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction,
15495 ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,15507 ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,
15496 IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)15508 IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)
...@@ -15931,11 +15943,10 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -15931,11 +15943,10 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
15931 IrInstruction *result_loc;15943 IrInstruction *result_loc;
15932 if (handle_is_ptr(impl_fn_type_id->return_type)) {15944 if (handle_is_ptr(impl_fn_type_id->return_type)) {
15933 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,15945 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
15934 impl_fn_type_id->return_type, nullptr);15946 impl_fn_type_id->return_type, nullptr, true);
15935 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {15947 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
15936 return result_loc;15948 return result_loc;
15937 }15949 }
15938 mark_inferred_ptr_runtime(result_loc);
15939 } else {15950 } else {
15940 result_loc = nullptr;15951 result_loc = nullptr;
15941 }15952 }
...@@ -16052,11 +16063,10 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -16052,11 +16063,10 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
16052 IrInstruction *result_loc;16063 IrInstruction *result_loc;
16053 if (handle_is_ptr(return_type)) {16064 if (handle_is_ptr(return_type)) {
16054 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,16065 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
16055 return_type, nullptr);16066 return_type, nullptr, true);
16056 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {16067 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
16057 return result_loc;16068 return result_loc;
16058 }16069 }
16059 mark_inferred_ptr_runtime(result_loc);
16060 } else {16070 } else {
16061 result_loc = nullptr;16071 result_loc = nullptr;
16062 }16072 }
...@@ -16547,7 +16557,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh...@@ -16547,7 +16557,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1654716557
16548 // In case resolving the parent activates a suspend, do it now16558 // In case resolving the parent activates a suspend, do it now
16549 IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent,16559 IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent,
16550 peer_parent->resolved_type, nullptr);16560 peer_parent->resolved_type, nullptr, false);
16551 if (parent_result_loc != nullptr &&16561 if (parent_result_loc != nullptr &&
16552 (type_is_invalid(parent_result_loc->value.type) || instr_is_unreachable(parent_result_loc)))16562 (type_is_invalid(parent_result_loc->value.type) || instr_is_unreachable(parent_result_loc)))
16553 {16563 {
...@@ -16893,19 +16903,45 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -16893,19 +16903,45 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
16893 if (array_ptr_val == nullptr)16903 if (array_ptr_val == nullptr)
16894 return ira->codegen->invalid_instruction;16904 return ira->codegen->invalid_instruction;
1689516905
16896 if (array_ptr_val->special == ConstValSpecialUndef && array_type->id == ZigTypeIdArray &&16906 if (array_ptr_val->special == ConstValSpecialUndef && elem_ptr_instruction->init_array_type != nullptr) {
16897 elem_ptr_instruction->initializing)16907 if (array_type->id == ZigTypeIdArray) {
16898 {16908 array_ptr_val->data.x_array.special = ConstArraySpecialNone;
16899 array_ptr_val->data.x_array.special = ConstArraySpecialNone;16909 array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len);
16900 array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len);16910 array_ptr_val->special = ConstValSpecialStatic;
16901 array_ptr_val->special = ConstValSpecialStatic;16911 for (size_t i = 0; i < array_type->data.array.len; i += 1) {
16902 for (size_t i = 0; i < array_type->data.array.len; i += 1) {16912 ConstExprValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i];
16903 ConstExprValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i];16913 elem_val->special = ConstValSpecialUndef;
16904 elem_val->special = ConstValSpecialUndef;16914 elem_val->type = array_type->data.array.child_type;
16905 elem_val->type = array_type->data.array.child_type;16915 elem_val->parent.id = ConstParentIdArray;
16906 elem_val->parent.id = ConstParentIdArray;16916 elem_val->parent.data.p_array.array_val = array_ptr_val;
16907 elem_val->parent.data.p_array.array_val = array_ptr_val;16917 elem_val->parent.data.p_array.elem_index = i;
16908 elem_val->parent.data.p_array.elem_index = i;16918 }
16919 } else if (is_slice(array_type)) {
16920 ZigType *actual_array_type = ir_resolve_type(ira, elem_ptr_instruction->init_array_type->child);
16921 if (type_is_invalid(actual_array_type))
16922 return ira->codegen->invalid_instruction;
16923 assert(actual_array_type->id == ZigTypeIdArray);
16924
16925 ConstExprValue *array_init_val = create_const_vals(1);
16926 array_init_val->special = ConstValSpecialStatic;
16927 array_init_val->type = actual_array_type;
16928 array_init_val->data.x_array.special = ConstArraySpecialNone;
16929 array_init_val->data.x_array.data.s_none.elements = create_const_vals(actual_array_type->data.array.len);
16930 array_init_val->special = ConstValSpecialStatic;
16931 for (size_t i = 0; i < actual_array_type->data.array.len; i += 1) {
16932 ConstExprValue *elem_val = &array_init_val->data.x_array.data.s_none.elements[i];
16933 elem_val->special = ConstValSpecialUndef;
16934 elem_val->type = actual_array_type->data.array.child_type;
16935 elem_val->parent.id = ConstParentIdArray;
16936 elem_val->parent.data.p_array.array_val = array_init_val;
16937 elem_val->parent.data.p_array.elem_index = i;
16938 }
16939
16940 init_const_slice(ira->codegen, array_ptr_val, array_init_val, 0, actual_array_type->data.array.len,
16941 false);
16942 array_ptr_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.mut = ConstPtrMutInfer;
16943 } else {
16944 zig_unreachable();
16909 }16945 }
16910 }16946 }
1691116947
...@@ -16976,7 +17012,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -16976,7 +17012,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
16976 if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {17012 if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {
16977 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,17013 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
16978 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false,17014 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false,
16979 elem_ptr_instruction->ptr_len, false);17015 elem_ptr_instruction->ptr_len, nullptr);
16980 result->value.type = return_type;17016 result->value.type = return_type;
16981 return result;17017 return result;
16982 }17018 }
...@@ -17033,7 +17069,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -17033,7 +17069,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
17033 if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {17069 if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
17034 result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,17070 result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
17035 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index,17071 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index,
17036 false, elem_ptr_instruction->ptr_len, elem_ptr_instruction->initializing);17072 false, elem_ptr_instruction->ptr_len, elem_ptr_instruction->init_array_type);
17037 result->value.type = return_type;17073 result->value.type = return_type;
17038 result->value.special = ConstValSpecialStatic;17074 result->value.special = ConstValSpecialStatic;
17039 } else {17075 } else {
...@@ -17077,7 +17113,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -17077,7 +17113,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1707717113
17078 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,17114 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
17079 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on,17115 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on,
17080 elem_ptr_instruction->ptr_len, elem_ptr_instruction->initializing);17116 elem_ptr_instruction->ptr_len, elem_ptr_instruction->init_array_type);
17081 result->value.type = return_type;17117 result->value.type = return_type;
17082 return result;17118 return result;
17083}17119}
...@@ -18963,7 +18999,7 @@ static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrI...@@ -18963,7 +18999,7 @@ static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrI
18963 if (instr_is_comptime(field_result_loc) &&18999 if (instr_is_comptime(field_result_loc) &&
18964 field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)19000 field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
18965 {19001 {
18966 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;19002 // nothing
18967 } else {19003 } else {
18968 result_loc->value.special = ConstValSpecialRuntime;19004 result_loc->value.special = ConstValSpecialRuntime;
18969 }19005 }
...@@ -19099,9 +19135,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc...@@ -19099,9 +19135,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
19099 return ira->codegen->invalid_instruction;19135 return ira->codegen->invalid_instruction;
1910019136
19101 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {19137 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
19102 if (const_ptrs.length == actual_field_count) {19138 if (const_ptrs.length != actual_field_count) {
19103 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
19104 } else {
19105 result_loc->value.special = ConstValSpecialRuntime;19139 result_loc->value.special = ConstValSpecialRuntime;
19106 for (size_t i = 0; i < const_ptrs.length; i += 1) {19140 for (size_t i = 0; i < const_ptrs.length; i += 1) {
19107 IrInstruction *field_result_loc = const_ptrs.at(i);19141 IrInstruction *field_result_loc = const_ptrs.at(i);
...@@ -19218,9 +19252,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -19218,9 +19252,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
19218 }19252 }
1921919253
19220 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {19254 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
19221 if (const_ptrs.length == elem_count) {19255 if (const_ptrs.length != elem_count) {
19222 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
19223 } else {
19224 result_loc->value.special = ConstValSpecialRuntime;19256 result_loc->value.special = ConstValSpecialRuntime;
19225 for (size_t i = 0; i < const_ptrs.length; i += 1) {19257 for (size_t i = 0; i < const_ptrs.length; i += 1) {
19226 IrInstruction *elem_result_loc = const_ptrs.at(i);19258 IrInstruction *elem_result_loc = const_ptrs.at(i);
...@@ -20884,18 +20916,6 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi...@@ -20884,18 +20916,6 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
20884 if (type_is_invalid(ptr->value.type))20916 if (type_is_invalid(ptr->value.type))
20885 return ira->codegen->invalid_instruction;20917 return ira->codegen->invalid_instruction;
2088620918
20887 ZigType *result_type = get_optional_type(ira->codegen, operand_type);
20888 IrInstruction *result_loc;
20889 if (handle_is_ptr(result_type)) {
20890 result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
20891 result_type, nullptr);
20892 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
20893 return result_loc;
20894 }
20895 } else {
20896 result_loc = nullptr;
20897 }
20898
20899 // TODO let this be volatile20919 // TODO let this be volatile
20900 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);20920 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
20901 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);20921 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);
...@@ -20959,6 +20979,18 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi...@@ -20959,6 +20979,18 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
20959 zig_panic("TODO compile-time execution of cmpxchg");20979 zig_panic("TODO compile-time execution of cmpxchg");
20960 }20980 }
2096120981
20982 ZigType *result_type = get_optional_type(ira->codegen, operand_type);
20983 IrInstruction *result_loc;
20984 if (handle_is_ptr(result_type)) {
20985 result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
20986 result_type, nullptr, true);
20987 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
20988 return result_loc;
20989 }
20990 } else {
20991 result_loc = nullptr;
20992 }
20993
20962 return ir_build_cmpxchg_gen(ira, &instruction->base, result_type,20994 return ir_build_cmpxchg_gen(ira, &instruction->base, result_type,
20963 casted_ptr, casted_cmp_value, casted_new_value,20995 casted_ptr, casted_cmp_value, casted_new_value,
20964 success_order, failure_order, instruction->is_weak, result_loc);20996 success_order, failure_order, instruction->is_weak, result_loc);
...@@ -21208,7 +21240,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru...@@ -21208,7 +21240,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
21208 }21240 }
2120921241
21210 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,21242 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
21211 dest_slice_type, nullptr);21243 dest_slice_type, nullptr, true);
21212 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {21244 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
21213 return result_loc;21245 return result_loc;
21214 }21246 }
...@@ -21285,7 +21317,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct...@@ -21285,7 +21317,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
21285 }21317 }
2128621318
21287 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,21319 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
21288 dest_slice_type, nullptr);21320 dest_slice_type, nullptr, true);
21289 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {21321 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
21290 return result_loc;21322 return result_loc;
21291 }21323 }
...@@ -22027,7 +22059,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction...@@ -22027,7 +22059,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
22027 }22059 }
2202822060
22029 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,22061 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
22030 return_type, nullptr);22062 return_type, nullptr, true);
22031 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {22063 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
22032 return result_loc;22064 return result_loc;
22033 }22065 }
...@@ -24461,7 +24493,7 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct...@@ -24461,7 +24493,7 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
24461 bool want_resolve_result = !instruction->result_loc->written;24493 bool want_resolve_result = !instruction->result_loc->written;
24462 if (want_resolve_result) {24494 if (want_resolve_result) {
24463 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,24495 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
24464 value->value.type, value);24496 value->value.type, value, false);
24465 if (result_loc != nullptr) {24497 if (result_loc != nullptr) {
24466 if (type_is_invalid(result_loc->value.type))24498 if (type_is_invalid(result_loc->value.type))
24467 return ira->codegen->invalid_instruction;24499 return ira->codegen->invalid_instruction;
...@@ -24470,6 +24502,13 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct...@@ -24470,6 +24502,13 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
2447024502
24471 instruction->result_loc->written = true;24503 instruction->result_loc->written = true;
24472 ir_analyze_store_ptr(ira, &instruction->base, result_loc, value);24504 ir_analyze_store_ptr(ira, &instruction->base, result_loc, value);
24505 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
24506 if (instr_is_comptime(value)) {
24507 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
24508 } else {
24509 result_loc->value.special = ConstValSpecialRuntime;
24510 }
24511 }
24473 }24512 }
24474 }24513 }
2447524514
...@@ -24482,7 +24521,7 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst...@@ -24482,7 +24521,7 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst
24482 return operand;24521 return operand;
2448324522
24484 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,24523 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,
24485 &instruction->result_loc_bit_cast->base, operand->value.type, operand);24524 &instruction->result_loc_bit_cast->base, operand->value.type, operand, false);
24486 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))24525 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
24487 return result_loc;24526 return result_loc;
2448824527