| ... | ... | @@ -616,10 +616,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionRef *) { |
| 616 | 616 | return IrInstructionIdRef; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | | static constexpr IrInstructionId ir_instruction_id(IrInstructionStructInit *) { |
| 620 | | return IrInstructionIdStructInit; |
| 621 | | } |
| 622 | | |
| 623 | 619 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionInit *) { |
| 624 | 620 | return IrInstructionIdUnionInit; |
| 625 | 621 | } |
| ... | ... | @@ -888,6 +884,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionImplicitCast *) |
| 888 | 884 | return IrInstructionIdImplicitCast; |
| 889 | 885 | } |
| 890 | 886 | |
| 887 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResolveResult *) { |
| 888 | return IrInstructionIdResolveResult; |
| 889 | } |
| 890 | |
| 891 | 891 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOpaqueType *) { |
| 892 | 892 | return IrInstructionIdOpaqueType; |
| 893 | 893 | } |
| ... | ... | @@ -1517,20 +1517,6 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop |
| 1517 | 1517 | return &container_init_fields_instruction->base; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | | static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1521 | | ZigType *struct_type, size_t field_count, IrInstructionStructInitField *fields) |
| 1522 | | { |
| 1523 | | IrInstructionStructInit *struct_init_instruction = ir_build_instruction<IrInstructionStructInit>(irb, scope, source_node); |
| 1524 | | struct_init_instruction->struct_type = struct_type; |
| 1525 | | struct_init_instruction->field_count = field_count; |
| 1526 | | struct_init_instruction->fields = fields; |
| 1527 | | |
| 1528 | | for (size_t i = 0; i < field_count; i += 1) |
| 1529 | | ir_ref_instruction(fields[i].value, irb->current_basic_block); |
| 1530 | | |
| 1531 | | return &struct_init_instruction->base; |
| 1532 | | } |
| 1533 | | |
| 1534 | 1520 | static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1535 | 1521 | ZigType *union_type, TypeUnionField *field, IrInstruction *init_value) |
| 1536 | 1522 | { |
| ... | ... | @@ -2764,6 +2750,18 @@ static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNo |
| 2764 | 2750 | return &instruction->base; |
| 2765 | 2751 | } |
| 2766 | 2752 | |
| 2753 | static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 2754 | ResultLoc *result_loc, IrInstruction *ty) |
| 2755 | { |
| 2756 | IrInstructionResolveResult *instruction = ir_build_instruction<IrInstructionResolveResult>(irb, scope, source_node); |
| 2757 | instruction->result_loc = result_loc; |
| 2758 | instruction->ty = ty; |
| 2759 | |
| 2760 | ir_ref_instruction(ty, irb->current_basic_block); |
| 2761 | |
| 2762 | return &instruction->base; |
| 2763 | } |
| 2764 | |
| 2767 | 2765 | static IrInstruction *ir_build_opaque_type(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 2768 | 2766 | IrInstructionOpaqueType *instruction = ir_build_instruction<IrInstructionOpaqueType>(irb, scope, source_node); |
| 2769 | 2767 | |
| ... | ... | @@ -3220,6 +3218,7 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco |
| 3220 | 3218 | case ScopeIdSuspend: |
| 3221 | 3219 | case ScopeIdCompTime: |
| 3222 | 3220 | case ScopeIdRuntime: |
| 3221 | case ScopeIdElide: |
| 3223 | 3222 | scope = scope->parent; |
| 3224 | 3223 | continue; |
| 3225 | 3224 | case ScopeIdDeferExpr: |
| ... | ... | @@ -3276,6 +3275,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 3276 | 3275 | case ScopeIdSuspend: |
| 3277 | 3276 | case ScopeIdCompTime: |
| 3278 | 3277 | case ScopeIdRuntime: |
| 3278 | case ScopeIdElide: |
| 3279 | 3279 | scope = scope->parent; |
| 3280 | 3280 | continue; |
| 3281 | 3281 | case ScopeIdDeferExpr: |
| ... | ... | @@ -5549,7 +5549,9 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod |
| 5549 | 5549 | zig_unreachable(); |
| 5550 | 5550 | } |
| 5551 | 5551 | |
| 5552 | | static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5552 | static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, |
| 5553 | ResultLoc *result_loc) |
| 5554 | { |
| 5553 | 5555 | assert(node->type == NodeTypeContainerInitExpr); |
| 5554 | 5556 | |
| 5555 | 5557 | AstNodeContainerInitExpr *container_init_expr = &node->data.container_init_expr; |
| ... | ... | @@ -5559,39 +5561,61 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 5559 | 5561 | if (container_type == irb->codegen->invalid_instruction) |
| 5560 | 5562 | return container_type; |
| 5561 | 5563 | |
| 5562 | | if (kind == ContainerInitKindStruct) { |
| 5563 | | size_t field_count = container_init_expr->entries.length; |
| 5564 | | IrInstructionContainerInitFieldsField *fields = allocate<IrInstructionContainerInitFieldsField>(field_count); |
| 5565 | | for (size_t i = 0; i < field_count; i += 1) { |
| 5566 | | AstNode *entry_node = container_init_expr->entries.at(i); |
| 5567 | | assert(entry_node->type == NodeTypeStructValueField); |
| 5568 | | |
| 5569 | | Buf *name = entry_node->data.struct_val_field.name; |
| 5570 | | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 5571 | | IrInstruction *expr_value = ir_gen_node(irb, expr_node, scope); |
| 5572 | | if (expr_value == irb->codegen->invalid_instruction) |
| 5573 | | return expr_value; |
| 5574 | | |
| 5575 | | fields[i].name = name; |
| 5576 | | fields[i].value = expr_value; |
| 5577 | | fields[i].source_node = entry_node; |
| 5578 | | } |
| 5579 | | return ir_build_container_init_fields(irb, scope, node, container_type, field_count, fields); |
| 5580 | | } else if (kind == ContainerInitKindArray) { |
| 5581 | | size_t item_count = container_init_expr->entries.length; |
| 5582 | | IrInstruction **values = allocate<IrInstruction *>(item_count); |
| 5583 | | for (size_t i = 0; i < item_count; i += 1) { |
| 5584 | | AstNode *expr_node = container_init_expr->entries.at(i); |
| 5585 | | IrInstruction *expr_value = ir_gen_node(irb, expr_node, scope); |
| 5586 | | if (expr_value == irb->codegen->invalid_instruction) |
| 5587 | | return expr_value; |
| 5588 | | |
| 5589 | | values[i] = expr_value; |
| 5590 | | } |
| 5591 | | return ir_build_container_init_list(irb, scope, node, container_type, item_count, values); |
| 5592 | | } else { |
| 5593 | | zig_unreachable(); |
| 5564 | switch (kind) { |
| 5565 | case ContainerInitKindStruct: { |
| 5566 | src_assert(result_loc->scope_elide == nullptr, node); |
| 5567 | result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope); |
| 5568 | size_t field_count = container_init_expr->entries.length; |
| 5569 | IrInstructionContainerInitFieldsField *fields = allocate<IrInstructionContainerInitFieldsField>(field_count); |
| 5570 | for (size_t i = 0; i < field_count; i += 1) { |
| 5571 | AstNode *entry_node = container_init_expr->entries.at(i); |
| 5572 | assert(entry_node->type == NodeTypeStructValueField); |
| 5573 | |
| 5574 | Buf *name = entry_node->data.struct_val_field.name; |
| 5575 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 5576 | |
| 5577 | ResultLoc *child_result_loc = nullptr; |
| 5578 | if (result_loc != nullptr) { |
| 5579 | IrInstruction *container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base, |
| 5580 | expr_node, result_loc, container_type); |
| 5581 | IrInstruction *field_ptr = ir_build_field_ptr(irb, &result_loc->scope_elide->base, expr_node, |
| 5582 | container_ptr, name); |
| 5583 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 5584 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5585 | result_loc_inst->base.source_instruction = field_ptr; |
| 5586 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 5587 | child_result_loc = &result_loc_inst->base; |
| 5588 | } |
| 5589 | |
| 5590 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, &result_loc->scope_elide->base, |
| 5591 | LValNone, child_result_loc); |
| 5592 | if (expr_value == irb->codegen->invalid_instruction) |
| 5593 | return expr_value; |
| 5594 | |
| 5595 | fields[i].name = name; |
| 5596 | fields[i].value = expr_value; |
| 5597 | fields[i].source_node = entry_node; |
| 5598 | } |
| 5599 | IrInstruction *init_fields = ir_build_container_init_fields(irb, scope, node, container_type, field_count, fields); |
| 5600 | |
| 5601 | return ir_lval_wrap(irb, scope, init_fields, lval, result_loc); |
| 5602 | } |
| 5603 | case ContainerInitKindArray: { |
| 5604 | size_t item_count = container_init_expr->entries.length; |
| 5605 | IrInstruction **values = allocate<IrInstruction *>(item_count); |
| 5606 | for (size_t i = 0; i < item_count; i += 1) { |
| 5607 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 5608 | IrInstruction *expr_value = ir_gen_node(irb, expr_node, scope); |
| 5609 | if (expr_value == irb->codegen->invalid_instruction) |
| 5610 | return expr_value; |
| 5611 | |
| 5612 | values[i] = expr_value; |
| 5613 | } |
| 5614 | IrInstruction *init_list = ir_build_container_init_list(irb, scope, node, container_type, item_count, values); |
| 5615 | return ir_lval_wrap(irb, scope, init_list, lval, result_loc); |
| 5616 | } |
| 5594 | 5617 | } |
| 5618 | zig_unreachable(); |
| 5595 | 5619 | } |
| 5596 | 5620 | |
| 5597 | 5621 | static ResultLocVar *create_var_result_loc(IrInstruction *alloca, ZigVar *var) { |
| ... | ... | @@ -7885,7 +7909,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7885 | 7909 | case NodeTypePrefixOpExpr: |
| 7886 | 7910 | return ir_gen_prefix_op_expr(irb, scope, node, lval, result_loc); |
| 7887 | 7911 | case NodeTypeContainerInitExpr: |
| 7888 | | return ir_lval_wrap(irb, scope, ir_gen_container_init_expr(irb, scope, node), lval, result_loc); |
| 7912 | return ir_gen_container_init_expr(irb, scope, node, lval, result_loc); |
| 7889 | 7913 | case NodeTypeVariableDeclaration: |
| 7890 | 7914 | return ir_lval_wrap(irb, scope, ir_gen_var_decl(irb, scope, node), lval, result_loc); |
| 7891 | 7915 | case NodeTypeWhileExpr: |
| ... | ... | @@ -14468,7 +14492,9 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 14468 | 14492 | return &result->base; |
| 14469 | 14493 | } |
| 14470 | 14494 | |
| 14471 | | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, ResultLoc *result_loc) { |
| 14495 | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspend_source_instr, |
| 14496 | ResultLoc *result_loc) |
| 14497 | { |
| 14472 | 14498 | switch (result_loc->id) { |
| 14473 | 14499 | case ResultLocIdInvalid: |
| 14474 | 14500 | case ResultLocIdPeerParent: |
| ... | ... | @@ -14476,6 +14502,30 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, ResultLoc *result_lo |
| 14476 | 14502 | case ResultLocIdNone: |
| 14477 | 14503 | case ResultLocIdVar: |
| 14478 | 14504 | return nullptr; |
| 14505 | case ResultLocIdInstruction: |
| 14506 | return result_loc->source_instruction->child->value.type; |
| 14507 | case ResultLocIdField: { |
| 14508 | if (result_loc->resolved_loc != nullptr) { |
| 14509 | ZigType *ptr_type = result_loc->resolved_loc->value.type; |
| 14510 | assert(ptr_type->id == ZigTypeIdPointer); |
| 14511 | return ptr_type->data.pointer.child_type; |
| 14512 | } |
| 14513 | ResultLocField *result_loc_field = reinterpret_cast<ResultLocField *>(result_loc); |
| 14514 | ZigType *container_type = ir_resolve_type(ira, result_loc_field->container_type->child); |
| 14515 | if (type_is_invalid(container_type)) |
| 14516 | return ira->codegen->builtin_types.entry_invalid; |
| 14517 | if (container_type->id == ZigTypeIdStruct) { |
| 14518 | TypeStructField *field = find_struct_type_field(container_type, result_loc_field->name); |
| 14519 | if (field == nullptr) { |
| 14520 | return ira->codegen->builtin_types.entry_invalid; |
| 14521 | } |
| 14522 | return field->type_entry; |
| 14523 | } else if (container_type->id == ZigTypeIdUnion) { |
| 14524 | zig_panic("TODO"); |
| 14525 | } else { |
| 14526 | zig_unreachable(); |
| 14527 | } |
| 14528 | } |
| 14479 | 14529 | case ResultLocIdReturn: |
| 14480 | 14530 | return ira->explicit_return_type; |
| 14481 | 14531 | case ResultLocIdPeer: |
| ... | ... | @@ -14491,7 +14541,10 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 14491 | 14541 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value) |
| 14492 | 14542 | { |
| 14493 | 14543 | if (result_loc->resolved_loc != nullptr) { |
| 14494 | | return result_loc->resolved_loc; |
| 14544 | // allow to redo the result location if the value is known and comptime and the previous one isn't |
| 14545 | if (value == nullptr || !instr_is_comptime(value) || instr_is_comptime(result_loc->resolved_loc)) { |
| 14546 | return result_loc->resolved_loc; |
| 14547 | } |
| 14495 | 14548 | } |
| 14496 | 14549 | result_loc->gen_instruction = value; |
| 14497 | 14550 | result_loc->implicit_elem_type = value_type; |
| ... | ... | @@ -14524,7 +14577,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 14524 | 14577 | return ira->codegen->invalid_instruction; |
| 14525 | 14578 | bool is_comptime = force_comptime || (value != nullptr && |
| 14526 | 14579 | value->value.special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); |
| 14527 | | if (alloca_src->base.child == nullptr) { |
| 14580 | if (alloca_src->base.child == nullptr || is_comptime) { |
| 14528 | 14581 | uint32_t align = 0; |
| 14529 | 14582 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, &align)) { |
| 14530 | 14583 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -14539,12 +14592,40 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 14539 | 14592 | alloca_gen = ir_analyze_alloca(ira, result_loc->source_instruction, value_type, align, |
| 14540 | 14593 | alloca_src->name_hint, force_comptime); |
| 14541 | 14594 | } |
| 14595 | if (alloca_src->base.child != nullptr) { |
| 14596 | alloca_src->base.child->ref_count = 0; |
| 14597 | } |
| 14542 | 14598 | alloca_src->base.child = alloca_gen; |
| 14543 | 14599 | } |
| 14544 | 14600 | result_loc->written = true; |
| 14545 | 14601 | result_loc->resolved_loc = is_comptime ? nullptr : alloca_src->base.child; |
| 14546 | 14602 | return result_loc->resolved_loc; |
| 14547 | 14603 | } |
| 14604 | case ResultLocIdInstruction: { |
| 14605 | result_loc->written = true; |
| 14606 | result_loc->resolved_loc = result_loc->source_instruction->child; |
| 14607 | return result_loc->resolved_loc; |
| 14608 | } |
| 14609 | case ResultLocIdField: { |
| 14610 | ResultLocField *result_loc_field = reinterpret_cast<ResultLocField *>(result_loc); |
| 14611 | |
| 14612 | ZigType *container_type = ir_resolve_type(ira, result_loc_field->container_type->child); |
| 14613 | if (type_is_invalid(container_type)) |
| 14614 | return ira->codegen->invalid_instruction; |
| 14615 | |
| 14616 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, |
| 14617 | result_loc_field->parent, container_type, nullptr); |
| 14618 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || |
| 14619 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) |
| 14620 | { |
| 14621 | return parent_result_loc; |
| 14622 | } |
| 14623 | |
| 14624 | result_loc->written = true; |
| 14625 | result_loc->resolved_loc = ir_analyze_container_field_ptr(ira, result_loc_field->name, |
| 14626 | suspend_source_instr, parent_result_loc, container_type); |
| 14627 | return result_loc->resolved_loc; |
| 14628 | } |
| 14548 | 14629 | case ResultLocIdReturn: { |
| 14549 | 14630 | bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime; |
| 14550 | 14631 | if (is_comptime) return nullptr; |
| ... | ... | @@ -14593,7 +14674,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 14593 | 14674 | ira->resume_stack.append(opposite_peer->suspend_pos); |
| 14594 | 14675 | } |
| 14595 | 14676 | } |
| 14596 | | ZigType *expected_type = ir_result_loc_expected_type(ira, peer_parent->parent); |
| 14677 | ZigType *expected_type = ir_result_loc_expected_type(ira, suspend_source_instr, peer_parent->parent); |
| 14597 | 14678 | peer_parent->resolved_type = ir_resolve_peer_types(ira, |
| 14598 | 14679 | peer_parent->base.source_instruction->source_node, expected_type, instructions, |
| 14599 | 14680 | peer_parent->peer_count); |
| ... | ... | @@ -14626,6 +14707,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns |
| 14626 | 14707 | return ir_implicit_cast(ira, target, dest_type); |
| 14627 | 14708 | } |
| 14628 | 14709 | |
| 14710 | static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstructionResolveResult *instruction) { |
| 14711 | ZigType *ty = ir_resolve_type(ira, instruction->ty->child); |
| 14712 | if (type_is_invalid(ty)) |
| 14713 | return ira->codegen->invalid_instruction; |
| 14714 | return ir_resolve_result(ira, &instruction->base, instruction->result_loc, ty, nullptr); |
| 14715 | } |
| 14629 | 14716 | |
| 14630 | 14717 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry, |
| 14631 | 14718 | ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, |
| ... | ... | @@ -18330,8 +18417,6 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 18330 | 18417 | |
| 18331 | 18418 | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); |
| 18332 | 18419 | |
| 18333 | | IrInstructionStructInitField *new_fields = allocate<IrInstructionStructInitField>(actual_field_count); |
| 18334 | | |
| 18335 | 18420 | bool is_comptime = ir_should_inline(ira->new_irb.exec, instruction->scope) |
| 18336 | 18421 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; |
| 18337 | 18422 | |
| ... | ... | @@ -18371,9 +18456,6 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 18371 | 18456 | } |
| 18372 | 18457 | field_assign_nodes[field_index] = field->source_node; |
| 18373 | 18458 | |
| 18374 | | new_fields[field_index].value = casted_field_value; |
| 18375 | | new_fields[field_index].type_struct_field = type_field; |
| 18376 | | |
| 18377 | 18459 | if (const_val.special == ConstValSpecialStatic) { |
| 18378 | 18460 | if (is_comptime || casted_field_value->value.special != ConstValSpecialRuntime) { |
| 18379 | 18461 | ConstExprValue *field_val = ir_resolve_const(ira, casted_field_value, UndefOk); |
| ... | ... | @@ -18416,9 +18498,6 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 18416 | 18498 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); |
| 18417 | 18499 | copy_const_val(&runtime_inst->value, field->init_val, true); |
| 18418 | 18500 | |
| 18419 | | new_fields[i].value = runtime_inst; |
| 18420 | | new_fields[i].type_struct_field = field; |
| 18421 | | |
| 18422 | 18501 | if (const_val.special == ConstValSpecialStatic) { |
| 18423 | 18502 | copy_const_val(&const_val.data.x_struct.fields[i], field->init_val, true); |
| 18424 | 18503 | } |
| ... | ... | @@ -18451,12 +18530,11 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 18451 | 18530 | return ira->codegen->invalid_instruction; |
| 18452 | 18531 | } |
| 18453 | 18532 | |
| 18454 | | IrInstruction *new_instruction = ir_build_struct_init(&ira->new_irb, |
| 18455 | | instruction->scope, instruction->source_node, |
| 18456 | | container_type, actual_field_count, new_fields); |
| 18457 | | new_instruction->value.type = container_type; |
| 18458 | | ir_add_alloca(ira, new_instruction, container_type); |
| 18459 | | return new_instruction; |
| 18533 | // this instruction should not get to codegen |
| 18534 | IrInstruction *result = ir_const(ira, instruction, container_type); |
| 18535 | // this is how we signal to EndExpr the value is not comptime known |
| 18536 | result->value.special = ConstValSpecialRuntime; |
| 18537 | return result; |
| 18460 | 18538 | } |
| 18461 | 18539 | |
| 18462 | 18540 | static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| ... | ... | @@ -23794,7 +23872,18 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct |
| 23794 | 23872 | if (type_is_invalid(value->value.type)) |
| 23795 | 23873 | return ira->codegen->invalid_instruction; |
| 23796 | 23874 | |
| 23797 | | if (!instruction->result_loc->written) { |
| 23875 | bool want_resolve_result = instruction->result_loc->written; |
| 23876 | if (instruction->result_loc->written) { |
| 23877 | if (instruction->result_loc->scope_elide != nullptr && instr_is_comptime(value)) { |
| 23878 | want_resolve_result = true; |
| 23879 | instruction->result_loc->scope_elide->activated = true; |
| 23880 | } else { |
| 23881 | want_resolve_result = false; |
| 23882 | } |
| 23883 | } else { |
| 23884 | want_resolve_result = true; |
| 23885 | } |
| 23886 | if (want_resolve_result) { |
| 23798 | 23887 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 23799 | 23888 | value->value.type, value); |
| 23800 | 23889 | if (result_loc != nullptr) { |
| ... | ... | @@ -23815,7 +23904,6 @@ static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction |
| 23815 | 23904 | switch (instruction->id) { |
| 23816 | 23905 | case IrInstructionIdInvalid: |
| 23817 | 23906 | case IrInstructionIdWidenOrShorten: |
| 23818 | | case IrInstructionIdStructInit: |
| 23819 | 23907 | case IrInstructionIdUnionInit: |
| 23820 | 23908 | case IrInstructionIdStructFieldPtr: |
| 23821 | 23909 | case IrInstructionIdUnionFieldPtr: |
| ... | ... | @@ -24036,6 +24124,8 @@ static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction |
| 24036 | 24124 | return ir_analyze_instruction_align_cast(ira, (IrInstructionAlignCast *)instruction); |
| 24037 | 24125 | case IrInstructionIdImplicitCast: |
| 24038 | 24126 | return ir_analyze_instruction_implicit_cast(ira, (IrInstructionImplicitCast *)instruction); |
| 24127 | case IrInstructionIdResolveResult: |
| 24128 | return ir_analyze_instruction_resolve_result(ira, (IrInstructionResolveResult *)instruction); |
| 24039 | 24129 | case IrInstructionIdOpaqueType: |
| 24040 | 24130 | return ir_analyze_instruction_opaque_type(ira, (IrInstructionOpaqueType *)instruction); |
| 24041 | 24131 | case IrInstructionIdSetAlignStack: |
| ... | ... | @@ -24260,7 +24350,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 24260 | 24350 | case IrInstructionIdCast: |
| 24261 | 24351 | case IrInstructionIdContainerInitList: |
| 24262 | 24352 | case IrInstructionIdContainerInitFields: |
| 24263 | | case IrInstructionIdStructInit: |
| 24264 | 24353 | case IrInstructionIdUnionInit: |
| 24265 | 24354 | case IrInstructionIdFieldPtr: |
| 24266 | 24355 | case IrInstructionIdElemPtr: |
| ... | ... | @@ -24326,6 +24415,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 24326 | 24415 | case IrInstructionIdTypeId: |
| 24327 | 24416 | case IrInstructionIdAlignCast: |
| 24328 | 24417 | case IrInstructionIdImplicitCast: |
| 24418 | case IrInstructionIdResolveResult: |
| 24329 | 24419 | case IrInstructionIdOpaqueType: |
| 24330 | 24420 | case IrInstructionIdArgType: |
| 24331 | 24421 | case IrInstructionIdTagType: |