From a76b048354e5754b18ecd83ad21cf45c5a34e276 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 18 Dec 2016 13:37:50 -0500 Subject: IR: phi instruction handles unreachable values correctly --- src/codegen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 6dfa2520bc..dd734cbf63 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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; } } -- cgit v1.2.3