| ... | @@ -733,18 +733,21 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) { | ... | @@ -733,18 +733,21 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) { |
| 733 | | 733 | |
| 734 | static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) { | 734 | static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) { |
| 735 | ConstExprValue *val = &g->panic_msg_vals[msg_id]; | 735 | ConstExprValue *val = &g->panic_msg_vals[msg_id]; |
| 736 | if (val->global_refs->llvm_global) | 736 | if (!val->global_refs->llvm_global) { |
| 737 | return val->global_refs->llvm_global; | | |
| 738 | | 737 | |
| 739 | Buf *buf_msg = panic_msg_buf(msg_id); | 738 | Buf *buf_msg = panic_msg_buf(msg_id); |
| 740 | ConstExprValue *array_val = create_const_str_lit(g, buf_msg); | 739 | ConstExprValue *array_val = create_const_str_lit(g, buf_msg); |
| 741 | init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true); | 740 | init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true); |
| 742 | | 741 | |
| 743 | render_const_val(g, val); | 742 | render_const_val(g, val); |
| 744 | render_const_val_global(g, val, ""); | 743 | render_const_val_global(g, val, ""); |
| 745 | | 744 | |
| 746 | assert(val->global_refs->llvm_global); | 745 | assert(val->global_refs->llvm_global); |
| 747 | return val->global_refs->llvm_global; | 746 | } |
| | 747 | |
| | 748 | TypeTableEntry *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true); |
| | 749 | TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type); |
| | 750 | return LLVMConstBitCast(val->global_refs->llvm_global, LLVMPointerType(str_type->type_ref, 0)); |
| 748 | } | 751 | } |
| 749 | | 752 | |
| 750 | static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { | 753 | static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { |
| ... | @@ -3743,7 +3746,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { | ... | @@ -3743,7 +3746,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { |
| 3743 | fields[type_struct_field->gen_index] = gen_const_val(g, &const_val->data.x_struct.fields[i]); | 3746 | fields[type_struct_field->gen_index] = gen_const_val(g, &const_val->data.x_struct.fields[i]); |
| 3744 | } | 3747 | } |
| 3745 | } | 3748 | } |
| 3746 | return LLVMConstNamedStruct(type_entry->type_ref, fields, type_entry->data.structure.gen_field_count); | 3749 | return LLVMConstStruct(fields, type_entry->data.structure.gen_field_count, |
| | 3750 | type_entry->data.structure.layout == ContainerLayoutPacked); |
| 3747 | } | 3751 | } |
| 3748 | case TypeTableEntryIdUnion: | 3752 | case TypeTableEntryIdUnion: |
| 3749 | { | 3753 | { |