authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-21 23:04:04-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-21 23:04:04-05:00
log43be6ccb03e6ce32f78c69129b61d49cae2b747d
tree5658b04142baa382e795f18dca5a3efcaa58894e
parentb4c2f7e31018cd2abc882221096a1fd1e71d5b88

IR: fix phi instruction when one of the predecessors is unreachable


2 files changed, 5 insertions(+), 3 deletions(-)

src/analyze.cpp+1
......@@ -2268,6 +2268,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
22682268 if (block_return_type->id == TypeTableEntryIdInvalid ||
22692269 fn_table_entry->analyzed_executable.invalid)
22702270 {
2271 assert(g->errors.length > 0);
22712272 fn_table_entry->anal_state = FnAnalStateInvalid;
22722273 return;
22732274 }
src/ir.cpp+4-3
......@@ -6910,11 +6910,12 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
69106910 IrInstruction *old_value = phi_instruction->incoming_values[i];
69116911 assert(old_value);
69126912 IrInstruction *new_value = old_value->other;
6913 if (!new_value || new_value->type_entry->id == TypeTableEntryIdInvalid)
6913 if (!new_value || new_value->type_entry->id == TypeTableEntryIdUnreachable)
6914 continue;
6915
6916 if (new_value->type_entry->id == TypeTableEntryIdInvalid)
69146917 return ira->codegen->builtin_types.entry_invalid;
69156918
6916 if (new_value->type_entry->id == TypeTableEntryIdUnreachable)
6917 continue;
69186919
69196920 assert(predecessor->other);
69206921 new_incoming_blocks.append(predecessor->other);