From 5e6fc94b7f43dda028de779a874f12591fa0a50d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 1 Oct 2017 03:05:01 -0400 Subject: fix codegen on windows --- src/codegen.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index b9298f84cb..85509dcd2d 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -733,18 +733,21 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) { static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) { ConstExprValue *val = &g->panic_msg_vals[msg_id]; - if (val->global_refs->llvm_global) - return val->global_refs->llvm_global; + if (!val->global_refs->llvm_global) { - Buf *buf_msg = panic_msg_buf(msg_id); - ConstExprValue *array_val = create_const_str_lit(g, buf_msg); - init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true); + Buf *buf_msg = panic_msg_buf(msg_id); + ConstExprValue *array_val = create_const_str_lit(g, buf_msg); + init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true); - render_const_val(g, val); - render_const_val_global(g, val, ""); + render_const_val(g, val); + render_const_val_global(g, val, ""); - assert(val->global_refs->llvm_global); - return val->global_refs->llvm_global; + assert(val->global_refs->llvm_global); + } + + TypeTableEntry *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true); + TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type); + return LLVMConstBitCast(val->global_refs->llvm_global, LLVMPointerType(str_type->type_ref, 0)); } static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { @@ -3743,7 +3746,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { fields[type_struct_field->gen_index] = gen_const_val(g, &const_val->data.x_struct.fields[i]); } } - return LLVMConstNamedStruct(type_entry->type_ref, fields, type_entry->data.structure.gen_field_count); + return LLVMConstStruct(fields, type_entry->data.structure.gen_field_count, + type_entry->data.structure.layout == ContainerLayoutPacked); } case TypeTableEntryIdUnion: { -- cgit v1.2.3