diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-21 23:04:04 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-21 23:04:04 -0500 |
| commit | 43be6ccb03e6ce32f78c69129b61d49cae2b747d (patch) | |
| tree | 5658b04142baa382e795f18dca5a3efcaa58894e | |
| parent | b4c2f7e31018cd2abc882221096a1fd1e71d5b88 (diff) | |
| download | zig-43be6ccb03e6ce32f78c69129b61d49cae2b747d.tar.gz zig-43be6ccb03e6ce32f78c69129b61d49cae2b747d.zip | |
IR: fix phi instruction when one of the predecessors is unreachable
| -rw-r--r-- | src/analyze.cpp | 1 | ||||
| -rw-r--r-- | src/ir.cpp | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 20e1e87a34..f374920709 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2268,6 +2268,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { if (block_return_type->id == TypeTableEntryIdInvalid || fn_table_entry->analyzed_executable.invalid) { + assert(g->errors.length > 0); fn_table_entry->anal_state = FnAnalStateInvalid; return; } diff --git a/src/ir.cpp b/src/ir.cpp index ae629e0910..97d70e3e6a 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6910,11 +6910,12 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP IrInstruction *old_value = phi_instruction->incoming_values[i]; assert(old_value); IrInstruction *new_value = old_value->other; - if (!new_value || new_value->type_entry->id == TypeTableEntryIdInvalid) + if (!new_value || new_value->type_entry->id == TypeTableEntryIdUnreachable) + continue; + + if (new_value->type_entry->id == TypeTableEntryIdInvalid) return ira->codegen->builtin_types.entry_invalid; - if (new_value->type_entry->id == TypeTableEntryIdUnreachable) - continue; assert(predecessor->other); new_incoming_blocks.append(predecessor->other); |
