| ... | @@ -2834,7 +2834,7 @@ fn updateType( | ... | @@ -2834,7 +2834,7 @@ fn updateType( |
| 2834 | }, | 2834 | }, |
| 2835 | .enum_type => { | 2835 | .enum_type => { |
| 2836 | const loaded_enum = ip.loadEnumType(type_index); | 2836 | const loaded_enum = ip.loadEnumType(type_index); |
| 2837 | try wip_nav.abbrevCode(.enum_type); | 2837 | try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type); |
| 2838 | try wip_nav.strp(name); | 2838 | try wip_nav.strp(name); |
| 2839 | try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty)); | 2839 | try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty)); |
| 2840 | for (0..loaded_enum.names.len) |field_index| { | 2840 | for (0..loaded_enum.names.len) |field_index| { |
| ... | @@ -2844,7 +2844,7 @@ fn updateType( | ... | @@ -2844,7 +2844,7 @@ fn updateType( |
| 2844 | }, field_index); | 2844 | }, field_index); |
| 2845 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); | 2845 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); |
| 2846 | } | 2846 | } |
| 2847 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 2847 | if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 2848 | }, | 2848 | }, |
| 2849 | .func_type => |func_type| { | 2849 | .func_type => |func_type| { |
| 2850 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; | 2850 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; |
| ... | @@ -3052,7 +3052,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3052,7 +3052,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3052 | } | 3052 | } |
| 3053 | }, | 3053 | }, |
| 3054 | .@"packed" => { | 3054 | .@"packed" => { |
| 3055 | try wip_nav.abbrevCode(.packed_struct_type); | 3055 | try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type); |
| 3056 | try wip_nav.strp(name); | 3056 | try wip_nav.strp(name); |
| 3057 | try wip_nav.refType(Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); | 3057 | try wip_nav.refType(Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); |
| 3058 | var field_bit_offset: u16 = 0; | 3058 | var field_bit_offset: u16 = 0; |
| ... | @@ -3064,13 +3064,13 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3064,13 +3064,13 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3064 | try uleb128(diw, field_bit_offset); | 3064 | try uleb128(diw, field_bit_offset); |
| 3065 | field_bit_offset += @intCast(field_type.bitSize(pt)); | 3065 | field_bit_offset += @intCast(field_type.bitSize(pt)); |
| 3066 | } | 3066 | } |
| 3067 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 3067 | if (loaded_struct.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3068 | }, | 3068 | }, |
| 3069 | } | 3069 | } |
| 3070 | }, | 3070 | }, |
| 3071 | .enum_type => { | 3071 | .enum_type => { |
| 3072 | const loaded_enum = ip.loadEnumType(type_index); | 3072 | const loaded_enum = ip.loadEnumType(type_index); |
| 3073 | try wip_nav.abbrevCode(.enum_type); | 3073 | try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type); |
| 3074 | try wip_nav.strp(name); | 3074 | try wip_nav.strp(name); |
| 3075 | try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty)); | 3075 | try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty)); |
| 3076 | for (0..loaded_enum.names.len) |field_index| { | 3076 | for (0..loaded_enum.names.len) |field_index| { |
| ... | @@ -3080,11 +3080,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3080,11 +3080,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3080 | }, field_index); | 3080 | }, field_index); |
| 3081 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); | 3081 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); |
| 3082 | } | 3082 | } |
| 3083 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 3083 | if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3084 | }, | 3084 | }, |
| 3085 | .union_type => { | 3085 | .union_type => { |
| 3086 | const loaded_union = ip.loadUnionType(type_index); | 3086 | const loaded_union = ip.loadUnionType(type_index); |
| 3087 | try wip_nav.abbrevCode(.union_type); | 3087 | try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type); |
| 3088 | try wip_nav.strp(name); | 3088 | try wip_nav.strp(name); |
| 3089 | const union_layout = pt.getUnionLayout(loaded_union); | 3089 | const union_layout = pt.getUnionLayout(loaded_union); |
| 3090 | try uleb128(diw, union_layout.abi_size); | 3090 | try uleb128(diw, union_layout.abi_size); |
| ... | @@ -3133,7 +3133,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3133,7 +3133,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3133 | try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse | 3133 | try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3134 | field_type.abiAlignment(pt).toByteUnits().?); | 3134 | field_type.abiAlignment(pt).toByteUnits().?); |
| 3135 | } | 3135 | } |
| 3136 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 3136 | if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3137 | }, | 3137 | }, |
| 3138 | .opaque_type => { | 3138 | .opaque_type => { |
| 3139 | try wip_nav.abbrevCode(.namespace_struct_type); | 3139 | try wip_nav.abbrevCode(.namespace_struct_type); |
| ... | @@ -3599,7 +3599,9 @@ const AbbrevCode = enum { | ... | @@ -3599,7 +3599,9 @@ const AbbrevCode = enum { |
| 3599 | namespace_struct_type, | 3599 | namespace_struct_type, |
| 3600 | struct_type, | 3600 | struct_type, |
| 3601 | packed_struct_type, | 3601 | packed_struct_type, |
| | 3602 | empty_packed_struct_type, |
| 3602 | union_type, | 3603 | union_type, |
| | 3604 | empty_union_type, |
| 3603 | empty_inlined_func, | 3605 | empty_inlined_func, |
| 3604 | inlined_func, | 3606 | inlined_func, |
| 3605 | local_arg, | 3607 | local_arg, |
| ... | @@ -3974,6 +3976,13 @@ const AbbrevCode = enum { | ... | @@ -3974,6 +3976,13 @@ const AbbrevCode = enum { |
| 3974 | .{ .type, .ref_addr }, | 3976 | .{ .type, .ref_addr }, |
| 3975 | }, | 3977 | }, |
| 3976 | }, | 3978 | }, |
| | 3979 | .empty_packed_struct_type = .{ |
| | 3980 | .tag = .structure_type, |
| | 3981 | .attrs = &.{ |
| | 3982 | .{ .name, .strp }, |
| | 3983 | .{ .type, .ref_addr }, |
| | 3984 | }, |
| | 3985 | }, |
| 3977 | .union_type = .{ | 3986 | .union_type = .{ |
| 3978 | .tag = .union_type, | 3987 | .tag = .union_type, |
| 3979 | .children = true, | 3988 | .children = true, |
| ... | @@ -3983,6 +3992,14 @@ const AbbrevCode = enum { | ... | @@ -3983,6 +3992,14 @@ const AbbrevCode = enum { |
| 3983 | .{ .alignment, .udata }, | 3992 | .{ .alignment, .udata }, |
| 3984 | }, | 3993 | }, |
| 3985 | }, | 3994 | }, |
| | 3995 | .empty_union_type = .{ |
| | 3996 | .tag = .union_type, |
| | 3997 | .attrs = &.{ |
| | 3998 | .{ .name, .strp }, |
| | 3999 | .{ .byte_size, .udata }, |
| | 4000 | .{ .alignment, .udata }, |
| | 4001 | }, |
| | 4002 | }, |
| 3986 | .empty_inlined_func = .{ | 4003 | .empty_inlined_func = .{ |
| 3987 | .tag = .inlined_subroutine, | 4004 | .tag = .inlined_subroutine, |
| 3988 | .attrs = &.{ | 4005 | .attrs = &.{ |