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) {...@@ -2268,6 +2268,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
2268 if (block_return_type->id == TypeTableEntryIdInvalid ||2268 if (block_return_type->id == TypeTableEntryIdInvalid ||
2269 fn_table_entry->analyzed_executable.invalid)2269 fn_table_entry->analyzed_executable.invalid)
2270 {2270 {
2271 assert(g->errors.length > 0);
2271 fn_table_entry->anal_state = FnAnalStateInvalid;2272 fn_table_entry->anal_state = FnAnalStateInvalid;
2272 return;2273 return;
2273 }2274 }
src/ir.cpp+4-3
...@@ -6910,11 +6910,12 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP...@@ -6910,11 +6910,12 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
6910 IrInstruction *old_value = phi_instruction->incoming_values[i];6910 IrInstruction *old_value = phi_instruction->incoming_values[i];
6911 assert(old_value);6911 assert(old_value);
6912 IrInstruction *new_value = old_value->other;6912 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)
6914 return ira->codegen->builtin_types.entry_invalid;6917 return ira->codegen->builtin_types.entry_invalid;
69156918
6916 if (new_value->type_entry->id == TypeTableEntryIdUnreachable)
6917 continue;
69186919
6919 assert(predecessor->other);6920 assert(predecessor->other);
6920 new_incoming_blocks.append(predecessor->other);6921 new_incoming_blocks.append(predecessor->other);