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
signaturelock-open 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
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 {
36283628struct ResultLocPeer {
36293629 ResultLoc base;
36303630
3631 bool seen_before;
36313632 ResultLocPeerParent *parent;
36323633 IrBasicBlock *next_bb;
36333634 IrSuspendPosition suspend_pos;
src/ir.cpp+20-5
......@@ -10659,6 +10659,12 @@ static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instr
1065910659 return result;
1066010660}
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
1066210668static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) {
1066310669 return ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_void);
1066410670}
......@@ -14461,7 +14467,9 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1446114467 if (peer_parent->resolved_type == nullptr) {
1446214468 IrInstruction *suspended_inst = ira_suspend(ira, suspend_source_instr,
1446314469 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;
1446514473 if (!last_one) {
1446614474 return suspended_inst;
1446714475 }
......@@ -14472,13 +14480,20 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1447214480
1447314481 IrInstruction *gen_instruction = this_peer->base.gen_instruction;
1447414482 if (gen_instruction == nullptr) {
14475 instructions[i] = ir_const(ira, this_peer->base.source_instruction,
14476 this_peer->base.implicit_elem_type);
14477 instructions[i]->value.special = ConstValSpecialRuntime;
14483 // unreachable instructions will cause implicit_elem_type to be null
14484 if (this_peer->base.implicit_elem_type == nullptr) {
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 }
1447814491 } else {
1447914492 instructions[i] = gen_instruction;
1448014493 }
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 {
1448214497 ira->resume_stack.append(opposite_peer->suspend_pos);
1448314498 }
1448414499 }