authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-07 14:20:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-07 14:20:35-04:00
logec17f4ebbef624526ed68f4fffcb2c5eec71bef9
tree23f2670f3d0fc05792f04fa952952aa6746bd3a5
parent4c222a482fa3807fce8455aa54fe4931bee7bb37
signature Commit is signed but in an unrecognized format.

fix behavior for peer result locs with one prong unreachable


3 files changed, 21 insertions(+), 10 deletions(-)

BRANCH_TODO-5
...@@ -33,9 +33,4 @@ handle if with no else...@@ -33,9 +33,4 @@ handle if with no else
3333
3434
3535
36static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) {
37 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable);
38 result->value.special = ConstValSpecialStatic;
39 return result;
40}
4136
src/all_types.hpp+1
...@@ -3628,6 +3628,7 @@ struct IrSuspendPosition {...@@ -3628,6 +3628,7 @@ struct IrSuspendPosition {
3628struct ResultLocPeer {3628struct ResultLocPeer {
3629 ResultLoc base;3629 ResultLoc base;
36303630
3631 bool seen_before;
3631 ResultLocPeerParent *parent;3632 ResultLocPeerParent *parent;
3632 IrBasicBlock *next_bb;3633 IrBasicBlock *next_bb;
3633 IrSuspendPosition suspend_pos;3634 IrSuspendPosition suspend_pos;
src/ir.cpp+20-5
...@@ -10659,6 +10659,12 @@ static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instr...@@ -10659,6 +10659,12 @@ static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instr
10659 return result;10659 return result;
10660}10660}
1066110661
10662static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) {
10663 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable);
10664 result->value.special = ConstValSpecialStatic;
10665 return result;
10666}
10667
10662static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) {10668static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) {
10663 return ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_void);10669 return ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_void);
10664}10670}
...@@ -14461,7 +14467,9 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s...@@ -14461,7 +14467,9 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
14461 if (peer_parent->resolved_type == nullptr) {14467 if (peer_parent->resolved_type == nullptr) {
14462 IrInstruction *suspended_inst = ira_suspend(ira, suspend_source_instr,14468 IrInstruction *suspended_inst = ira_suspend(ira, suspend_source_instr,
14463 result_peer->next_bb, &result_peer->suspend_pos);14469 result_peer->next_bb, &result_peer->suspend_pos);
14464 bool last_one = (result_peer == &peer_parent->peers[peer_parent->peer_count - 1]);14470 bool last_one = result_peer->seen_before ||
14471 result_peer == &peer_parent->peers[peer_parent->peer_count - 1];
14472 result_peer->seen_before = true;
14465 if (!last_one) {14473 if (!last_one) {
14466 return suspended_inst;14474 return suspended_inst;
14467 }14475 }
...@@ -14472,13 +14480,20 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s...@@ -14472,13 +14480,20 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1447214480
14473 IrInstruction *gen_instruction = this_peer->base.gen_instruction;14481 IrInstruction *gen_instruction = this_peer->base.gen_instruction;
14474 if (gen_instruction == nullptr) {14482 if (gen_instruction == nullptr) {
14475 instructions[i] = ir_const(ira, this_peer->base.source_instruction,14483 // unreachable instructions will cause implicit_elem_type to be null
14476 this_peer->base.implicit_elem_type);14484 if (this_peer->base.implicit_elem_type == nullptr) {
14477 instructions[i]->value.special = ConstValSpecialRuntime;14485 instructions[i] = ir_const_unreachable(ira, this_peer->base.source_instruction);
14486 } else {
14487 instructions[i] = ir_const(ira, this_peer->base.source_instruction,
14488 this_peer->base.implicit_elem_type);
14489 instructions[i]->value.special = ConstValSpecialRuntime;
14490 }
14478 } else {14491 } else {
14479 instructions[i] = gen_instruction;14492 instructions[i] = gen_instruction;
14480 }14493 }
14481 if (opposite_peer->base.implicit_elem_type->id != ZigTypeIdUnreachable) {14494 if (opposite_peer->base.implicit_elem_type != nullptr &&
14495 opposite_peer->base.implicit_elem_type->id != ZigTypeIdUnreachable)
14496 {
14482 ira->resume_stack.append(opposite_peer->suspend_pos);14497 ira->resume_stack.append(opposite_peer->suspend_pos);
14483 }14498 }
14484 }14499 }