authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-22 16:33:36-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-22 20:08:05-04:00
logf47e1e148e48eedc8c2097b489472fa900b6e334
treef93ec985e07dc36cfe3dd385b3f96a066d62577a
parent874ad98f7ab0f5b7d2b5c035b974daf163474c29

Dwarf: add more childless special cases


1 files changed, 25 insertions(+), 8 deletions(-)

src/link/Dwarf.zig+25-8
......@@ -2834,7 +2834,7 @@ fn updateType(
28342834 },
28352835 .enum_type => {
28362836 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);
28382838 try wip_nav.strp(name);
28392839 try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty));
28402840 for (0..loaded_enum.names.len) |field_index| {
......@@ -2844,7 +2844,7 @@ fn updateType(
28442844 }, field_index);
28452845 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
28462846 }
2847 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2847 if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
28482848 },
28492849 .func_type => |func_type| {
28502850 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
30523052 }
30533053 },
30543054 .@"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);
30563056 try wip_nav.strp(name);
30573057 try wip_nav.refType(Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
30583058 var field_bit_offset: u16 = 0;
......@@ -3064,13 +3064,13 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30643064 try uleb128(diw, field_bit_offset);
30653065 field_bit_offset += @intCast(field_type.bitSize(pt));
30663066 }
3067 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3067 if (loaded_struct.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
30683068 },
30693069 }
30703070 },
30713071 .enum_type => {
30723072 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);
30743074 try wip_nav.strp(name);
30753075 try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty));
30763076 for (0..loaded_enum.names.len) |field_index| {
......@@ -3080,11 +3080,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
30803080 }, field_index);
30813081 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
30823082 }
3083 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3083 if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
30843084 },
30853085 .union_type => {
30863086 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);
30883088 try wip_nav.strp(name);
30893089 const union_layout = pt.getUnionLayout(loaded_union);
30903090 try uleb128(diw, union_layout.abi_size);
......@@ -3133,7 +3133,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
31333133 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
31343134 field_type.abiAlignment(pt).toByteUnits().?);
31353135 }
3136 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3136 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
31373137 },
31383138 .opaque_type => {
31393139 try wip_nav.abbrevCode(.namespace_struct_type);
......@@ -3599,7 +3599,9 @@ const AbbrevCode = enum {
35993599 namespace_struct_type,
36003600 struct_type,
36013601 packed_struct_type,
3602 empty_packed_struct_type,
36023603 union_type,
3604 empty_union_type,
36033605 empty_inlined_func,
36043606 inlined_func,
36053607 local_arg,
......@@ -3974,6 +3976,13 @@ const AbbrevCode = enum {
39743976 .{ .type, .ref_addr },
39753977 },
39763978 },
3979 .empty_packed_struct_type = .{
3980 .tag = .structure_type,
3981 .attrs = &.{
3982 .{ .name, .strp },
3983 .{ .type, .ref_addr },
3984 },
3985 },
39773986 .union_type = .{
39783987 .tag = .union_type,
39793988 .children = true,
......@@ -3983,6 +3992,14 @@ const AbbrevCode = enum {
39833992 .{ .alignment, .udata },
39843993 },
39853994 },
3995 .empty_union_type = .{
3996 .tag = .union_type,
3997 .attrs = &.{
3998 .{ .name, .strp },
3999 .{ .byte_size, .udata },
4000 .{ .alignment, .udata },
4001 },
4002 },
39864003 .empty_inlined_func = .{
39874004 .tag = .inlined_subroutine,
39884005 .attrs = &.{