| ... | @@ -181,7 +181,6 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -181,7 +181,6 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 181 | static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); | 181 | static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); |
| 182 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs); | 182 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs); |
| 183 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); | 183 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); |
| 184 | static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry); | | |
| 185 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 184 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 186 | ZigType *ptr_type); | 185 | ZigType *ptr_type); |
| 187 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 186 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| ... | @@ -10497,15 +10496,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10497,15 +10496,6 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10497 | } | 10496 | } |
| 10498 | } | 10497 | } |
| 10499 | | 10498 | |
| 10500 | static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) { | | |
| 10501 | if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) { | | |
| 10502 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | | |
| 10503 | if (fn_entry != nullptr) { | | |
| 10504 | fn_entry->alloca_list.append(instruction); | | |
| 10505 | } | | |
| 10506 | } | | |
| 10507 | } | | |
| 10508 | | | |
| 10509 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs) { | 10499 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs) { |
| 10510 | ConstGlobalRefs *global_refs = dest->global_refs; | 10500 | ConstGlobalRefs *global_refs = dest->global_refs; |
| 10511 | assert(!same_global_refs || src->global_refs != nullptr); | 10501 | assert(!same_global_refs || src->global_refs != nullptr); |
| ... | @@ -10631,7 +10621,7 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z | ... | @@ -10631,7 +10621,7 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z |
| 10631 | } | 10621 | } |
| 10632 | | 10622 | |
| 10633 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 10623 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 10634 | ZigType *wanted_type, CastOp cast_op, bool need_alloca) | 10624 | ZigType *wanted_type, CastOp cast_op) |
| 10635 | { | 10625 | { |
| 10636 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { | 10626 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { |
| 10637 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 10627 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| ... | @@ -10644,9 +10634,6 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10644,9 +10634,6 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10644 | } else { | 10634 | } else { |
| 10645 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); | 10635 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); |
| 10646 | result->value.type = wanted_type; | 10636 | result->value.type = wanted_type; |
| 10647 | if (need_alloca) { | | |
| 10648 | ir_add_alloca(ira, result, wanted_type); | | |
| 10649 | } | | |
| 10650 | return result; | 10637 | return result; |
| 10651 | } | 10638 | } |
| 10652 | } | 10639 | } |
| ... | @@ -12121,7 +12108,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12121,7 +12108,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12121 | if (const_cast_result.id == ConstCastResultIdInvalid) | 12108 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 12122 | return ira->codegen->invalid_instruction; | 12109 | return ira->codegen->invalid_instruction; |
| 12123 | if (const_cast_result.id == ConstCastResultIdOk) { | 12110 | if (const_cast_result.id == ConstCastResultIdOk) { |
| 12124 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop, false); | 12111 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); |
| 12125 | } | 12112 | } |
| 12126 | | 12113 | |
| 12127 | // cast from T to ?T | 12114 | // cast from T to ?T |
| ... | @@ -20752,7 +20739,7 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -20752,7 +20739,7 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 20752 | } else { | 20739 | } else { |
| 20753 | op = CastOpNumLitToConcrete; | 20740 | op = CastOpNumLitToConcrete; |
| 20754 | } | 20741 | } |
| 20755 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, op, false); | 20742 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, op); |
| 20756 | } else { | 20743 | } else { |
| 20757 | return ira->codegen->invalid_instruction; | 20744 | return ira->codegen->invalid_instruction; |
| 20758 | } | 20745 | } |
| ... | @@ -20975,7 +20962,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst | ... | @@ -20975,7 +20962,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst |
| 20975 | return ira->codegen->invalid_instruction; | 20962 | return ira->codegen->invalid_instruction; |
| 20976 | } | 20963 | } |
| 20977 | | 20964 | |
| 20978 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpIntToFloat, false); | 20965 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpIntToFloat); |
| 20979 | } | 20966 | } |
| 20980 | | 20967 | |
| 20981 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { | 20968 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { |
| ... | @@ -20997,7 +20984,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst | ... | @@ -20997,7 +20984,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 20997 | return ira->codegen->invalid_instruction; | 20984 | return ira->codegen->invalid_instruction; |
| 20998 | } | 20985 | } |
| 20999 | | 20986 | |
| 21000 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpFloatToInt, false); | 20987 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpFloatToInt); |
| 21001 | } | 20988 | } |
| 21002 | | 20989 | |
| 21003 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { | 20990 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { |
| ... | @@ -21049,7 +21036,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr | ... | @@ -21049,7 +21036,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr |
| 21049 | } | 21036 | } |
| 21050 | | 21037 | |
| 21051 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); | 21038 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); |
| 21052 | return ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt, false); | 21039 | return ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt); |
| 21053 | } | 21040 | } |
| 21054 | | 21041 | |
| 21055 | static IrInstruction *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) { | 21042 | static IrInstruction *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) { |