diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 6a7653b10..c1f5c90ed 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -2440,14 +2440,14 @@ main :: proc() { range_statements_with_multiple_return_values() threading_example() - when !ODIN_DEBUG { + // when !ODIN_DEBUG { /* This test causes the following error when compiled with -`debug`: `Kernel32.lib(KERNEL32.dll) : fatal error LNK1103: debugging information corrupt; recompile module` Only compile when not running under debug for now to not hold up CI for other commits. */ soa_struct_layout() - } + // } constant_literal_expressions() union_maybe() diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 0d4ee9fe3..4a73c03f2 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -684,6 +684,9 @@ void lb_debug_complete_types(lbModule *m) { } element_count = cast(unsigned)(bt->Struct.fields.count + element_offset); elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); + + isize field_size_bits = 8*type_size_of(bt) - element_offset*word_bits; + switch (bt->Struct.soa_kind) { case StructSoa_Slice: elements[0] = LLVMDIBuilderCreateMemberType( @@ -691,7 +694,7 @@ void lb_debug_complete_types(lbModule *m) { ".len", 4, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - 8*type_size_of(bt)-word_bits, + field_size_bits, LLVMDIFlagZero, lb_debug_type(m, t_int) ); break; @@ -701,7 +704,7 @@ void lb_debug_complete_types(lbModule *m) { ".len", 4, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - 8*type_size_of(bt)-word_bits + 0*word_bits, + field_size_bits + 0*word_bits, LLVMDIFlagZero, lb_debug_type(m, t_int) ); elements[1] = LLVMDIBuilderCreateMemberType( @@ -709,15 +712,15 @@ void lb_debug_complete_types(lbModule *m) { ".cap", 4, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - 8*type_size_of(bt)-word_bits + 1*word_bits, + field_size_bits + 1*word_bits, LLVMDIFlagZero, lb_debug_type(m, t_int) ); elements[2] = LLVMDIBuilderCreateMemberType( m->debug_builder, record_scope, - ".allocator", 12, + ".allocator", 10, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - 8*type_size_of(bt)-word_bits + 2*word_bits, + field_size_bits + 2*word_bits, LLVMDIFlagZero, lb_debug_type(m, t_allocator) ); break;