IR: phi instruction handles unreachable values correctly

This commit is contained in:
Andrew Kelley
2016-12-18 13:37:50 -05:00
parent b59841a80f
commit a76b048354
2 changed files with 13 additions and 5 deletions

View File

@@ -401,10 +401,14 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
}
static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *type) {
if (handle_is_ptr(type)) {
return ptr;
if (type_has_bits(type)) {
if (handle_is_ptr(type)) {
return ptr;
} else {
return LLVMBuildLoad(g->builder, ptr, "");
}
} else {
return LLVMBuildLoad(g->builder, ptr, "");
return nullptr;
}
}