diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-10 18:38:53 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-10 18:38:53 -0500 |
| commit | 6feae8a4e90118df26738316ab1fb49882ba6431 (patch) | |
| tree | 89c113d87eca49f10681c0b6c18c66f51ff0d6fb /src/codegen.cpp | |
| parent | 443e14afbd0615bd4902e53a31f70550a8d4497e (diff) | |
| download | zig-6feae8a4e90118df26738316ab1fb49882ba6431.tar.gz zig-6feae8a4e90118df26738316ab1fb49882ba6431.zip | |
IR: support error union type
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 5ae2f96b8e..c828b42ed1 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -680,11 +680,6 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) { } assert(instruction->llvm_value); } - if (instruction->static_value.special != ConstValSpecialRuntime) { - if (instruction->type_entry->id == TypeTableEntryIdPointer) { - return LLVMBuildLoad(g->builder, instruction->static_value.llvm_global, ""); - } - } return instruction->llvm_value; } @@ -1794,7 +1789,14 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, Ir } static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstructionPhi *instruction) { - LLVMValueRef phi = LLVMBuildPhi(g->builder, instruction->base.type_entry->type_ref, ""); + LLVMTypeRef phi_type; + if (handle_is_ptr(instruction->base.type_entry)) { + phi_type = LLVMPointerType(instruction->base.type_entry->type_ref, 0); + } else { + phi_type = instruction->base.type_entry->type_ref; + } + + LLVMValueRef phi = LLVMBuildPhi(g->builder, phi_type, ""); LLVMValueRef *incoming_values = allocate<LLVMValueRef>(instruction->incoming_count); LLVMBasicBlockRef *incoming_blocks = allocate<LLVMBasicBlockRef>(instruction->incoming_count); for (size_t i = 0; i < instruction->incoming_count; i += 1) { |
