| ... | @@ -9226,6 +9226,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP | ... | @@ -9226,6 +9226,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 9226 | return ira->codegen->builtin_types.entry_invalid; | 9226 | return ira->codegen->builtin_types.entry_invalid; |
| 9227 | } | 9227 | } |
| 9228 | | 9228 | |
| | 9229 | bool all_stack_ptrs = (resolved_type->id == TypeTableEntryIdPointer); |
| | 9230 | |
| 9229 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. | 9231 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. |
| 9230 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and | 9232 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and |
| 9231 | // then make sure the branch instruction is preserved. | 9233 | // then make sure the branch instruction is preserved. |
| ... | @@ -9238,12 +9240,23 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP | ... | @@ -9238,12 +9240,23 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 9238 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | 9240 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 9239 | new_incoming_values.items[i] = casted_value; | 9241 | new_incoming_values.items[i] = casted_value; |
| 9240 | predecessor->instruction_list.append(branch_instruction); | 9242 | predecessor->instruction_list.append(branch_instruction); |
| | 9243 | |
| | 9244 | if (all_stack_ptrs && (casted_value->value.special != ConstValSpecialRuntime || |
| | 9245 | casted_value->value.data.rh_ptr != RuntimeHintPtrStack)) |
| | 9246 | { |
| | 9247 | all_stack_ptrs = false; |
| | 9248 | } |
| 9241 | } | 9249 | } |
| 9242 | ir_set_cursor_at_end(&ira->new_irb, cur_bb); | 9250 | ir_set_cursor_at_end(&ira->new_irb, cur_bb); |
| 9243 | | 9251 | |
| 9244 | ir_build_phi_from(&ira->new_irb, &phi_instruction->base, new_incoming_blocks.length, | 9252 | IrInstruction *result = ir_build_phi_from(&ira->new_irb, &phi_instruction->base, new_incoming_blocks.length, |
| 9245 | new_incoming_blocks.items, new_incoming_values.items); | 9253 | new_incoming_blocks.items, new_incoming_values.items); |
| 9246 | | 9254 | |
| | 9255 | if (all_stack_ptrs) { |
| | 9256 | assert(result->value.special == ConstValSpecialRuntime); |
| | 9257 | result->value.data.rh_ptr = RuntimeHintPtrStack; |
| | 9258 | } |
| | 9259 | |
| 9247 | return resolved_type; | 9260 | return resolved_type; |
| 9248 | } | 9261 | } |
| 9249 | | 9262 | |