authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-05 15:06:33-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-07 16:11:00-04:00
log4582acf585911b4391b909e5bbe7dd635801477b
tree396e4fe071e2c5112204af9cf6684178f356c844
parentbf68590236d6d7ceb0283cb706d76717755c896a

Dwarf2: implement non-type decls


3 files changed, 346 insertions(+), 272 deletions(-)

src/link/Dwarf2.zig+340-267
......@@ -10,7 +10,7 @@ consts: std.ArrayList(Const),
1010globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global),
1111funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func),
1212decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, Decl),
13pending_decl: struct { di: Decl.Index, instance_val: InternPool.Index },
13pending_decl: struct { di: Decl.Index, instance: Decl.Instance },
1414
1515debug_abbrev: Abbrev,
1616frame: Frame,
......@@ -155,6 +155,12 @@ pub const Decl = struct {
155155 return &dwarf.decls.values()[@backingInt(di)];
156156 }
157157 };
158
159 const Instance = union(enum) {
160 none,
161 @"const": InternPool.Index,
162 global: InternPool.Nav.Index,
163 };
158164};
159165
160166pub const Frame = struct {
......@@ -1258,7 +1264,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {
12581264 .globals = .empty,
12591265 .funcs = .empty,
12601266 .decls = .empty,
1261 .pending_decl = .{ .di = undefined, .instance_val = .none },
1267 .pending_decl = .{ .di = undefined, .instance = .none },
12621268
12631269 .debug_abbrev = .{
12641270 .ni = .none,
......@@ -1468,7 +1474,7 @@ pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index {
14681474 return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null));
14691475}
14701476
1471fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index {
1477fn getConstDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index {
14721478 const ip = &dwarf.lf.comp.zcu.?.intern_pool;
14731479 switch (ip.indexToKey(val)) {
14741480 else => unreachable,
......@@ -1511,26 +1517,41 @@ fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Ind
15111517 }).srcInst(ip),
15121518 }
15131519}
1514pub fn getDecl(
1520fn getConstDecl(
1521 dwarf: *Dwarf,
1522 pt: Zcu.PerThread,
1523 instance_const: InternPool.Index,
1524) link.Error!link.MappedFile.Node.Index {
1525 return dwarf.getDecl(pt, dwarf.getConstDeclInst(instance_const) orelse {
1526 const cpi = try dwarf.getConst(pt, .fromInterned(instance_const));
1527 return Const.get(cpi, dwarf).debug_info_ni.unwrap().?;
1528 }, .{ .@"const" = instance_const });
1529}
1530fn getGlobalDecl(
15151531 dwarf: *Dwarf,
15161532 pt: Zcu.PerThread,
1517 instance_val: InternPool.Index,
1533 instance_global: InternPool.Nav.Index,
1534) link.Error!link.MappedFile.Node.Index {
1535 const ip = &pt.zcu.intern_pool;
1536 return dwarf.getDecl(pt, ip.getNav(instance_global).srcInst(ip), .{ .global = instance_global });
1537}
1538fn getDecl(
1539 dwarf: *Dwarf,
1540 pt: Zcu.PerThread,
1541 inst: InternPool.TrackedInst.Index,
1542 instance: Decl.Instance,
15181543) link.Error!link.MappedFile.Node.Index {
15191544 const comp = dwarf.lf.comp;
15201545 const gpa = comp.gpa;
15211546 const zcu = pt.zcu;
15221547 const ip = &zcu.intern_pool;
1523 const inst = dwarf.getDeclInst(instance_val) orelse {
1524 const cpi = try dwarf.getConst(pt, .fromInterned(instance_val));
1525 return Const.get(cpi, dwarf).debug_info_ni.unwrap().?;
1526 };
15271548 const decl_gop = try dwarf.decls.getOrPut(gpa, inst);
15281549 if (!decl_gop.found_existing) decl_gop.value_ptr.* = .{
15291550 .debug_info_ni = .none,
15301551 };
15311552 const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index));
15321553 if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni;
1533 dwarf.pending_decl = .{ .di = di, .instance_val = instance_val };
1554 dwarf.pending_decl = .{ .di = di, .instance = instance };
15341555 const debug_info_ni = if (dwarf.lf.cast(.elf2)) |elf| debug_info_ni: {
15351556 try elf.nodes.ensureUnusedCapacity(gpa, 1);
15361557 try elf.dwarf_decls.putNoClobber(gpa, di, .{
......@@ -1946,19 +1967,18 @@ pub fn genDebugRnglists(
19461967 try dr_w.writeByte(DW.RLE.end_of_list);
19471968}
19481969
1949pub fn updateComptimeNav(
1970pub fn updateComptimeGlobal(
19501971 dwarf: *Dwarf,
19511972 pt: Zcu.PerThread,
1952 ni: InternPool.Nav.Index,
1973 global: InternPool.Nav.Index,
19531974) link.Error!void {
19541975 const zcu = pt.zcu;
19551976 const ip = &zcu.intern_pool;
1956 const nav = ip.getNav(ni);
1977 const nav = ip.getNav(global);
19571978 log.debug("updateComptimeNav({f})", .{nav.fqn.fmt(ip)});
19581979 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
19591980 const nav_val: Value = .fromInterned(nav.resolved.?.value);
1960 const zf = zcu.fileByIndex(inst_info.file);
1961 const decl = zf.zir.?.getDeclaration(inst_info.inst);
1981 const decl = zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst);
19621982 switch (decl.kind) {
19631983 .unnamed_test, .@"test", .decltest => return,
19641984 .@"comptime", .@"const", .@"var" => {},
......@@ -1977,34 +1997,34 @@ pub fn updateComptimeNav(
19771997 .error_set_type,
19781998 .inferred_error_set_type,
19791999 .spirv_type,
1980 => try dwarf.genDeclType(pt, ni, &decl),
2000 => try dwarf.genDeclType(pt, global, &decl),
19812001 .struct_type => {
19822002 const loaded_struct = ip.loadStructType(nav_val.toIntern());
1983 if (ni.toOptional() == loaded_struct.name_nav)
2003 if (global.toOptional() == loaded_struct.name_nav)
19842004 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern())
19852005 else
1986 try dwarf.genDeclType(pt, ni, &decl);
2006 try dwarf.genDeclType(pt, global, &decl);
19872007 },
19882008 .enum_type => {
19892009 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
1990 if (ni.toOptional() == loaded_enum.name_nav)
2010 if (global.toOptional() == loaded_enum.name_nav)
19912011 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern())
19922012 else
1993 try dwarf.genDeclType(pt, ni, &decl);
2013 try dwarf.genDeclType(pt, global, &decl);
19942014 },
19952015 .union_type => {
19962016 const loaded_union = ip.loadUnionType(nav_val.toIntern());
1997 if (ni.toOptional() == loaded_union.name_nav)
2017 if (global.toOptional() == loaded_union.name_nav)
19982018 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern())
19992019 else
2000 try dwarf.genDeclType(pt, ni, &decl);
2020 try dwarf.genDeclType(pt, global, &decl);
20012021 },
20022022 .opaque_type => {
20032023 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
2004 if (ni.toOptional() == loaded_opaque.name_nav)
2024 if (global.toOptional() == loaded_opaque.name_nav)
20052025 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern())
20062026 else
2007 try dwarf.genDeclType(pt, ni, &decl);
2027 try dwarf.genDeclType(pt, global, &decl);
20082028 },
20092029 .undef,
20102030 .simple_value,
......@@ -2020,9 +2040,9 @@ pub fn updateComptimeNav(
20202040 .aggregate,
20212041 .un,
20222042 .bitpack,
2023 => try dwarf.genDeclValue(pt, ni, &decl),
2043 => try dwarf.genDeclGlobal(pt, global, &decl),
20242044 .@"extern" => unreachable,
2025 .func => |func| if (func.owner_nav == ni and func.generic_owner == .none) {
2045 .func => |func| if (func.owner_nav == global and func.generic_owner == .none) {
20262046 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
20272047 break :done;
20282048 } else return,
......@@ -2034,10 +2054,10 @@ pub fn updateComptimeNav(
20342054fn genDeclType(
20352055 dwarf: *Dwarf,
20362056 pt: Zcu.PerThread,
2037 ni: InternPool.Nav.Index,
2057 global: InternPool.Nav.Index,
20382058 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
20392059) link.Error!void {
2040 const gi = try dwarf.getGlobal(ni);
2060 const gi = try dwarf.getGlobal(global);
20412061 const debug_info_ni = gi.get(dwarf).debug_info_ni.unwrap().?;
20422062 var di_nw: link.MappedFile.Node.Writer = undefined;
20432063 if (dwarf.lf.cast(.elf2)) |elf| {
......@@ -2045,7 +2065,7 @@ fn genDeclType(
20452065 elf.resetNodeRelocs(debug_info_ni);
20462066 } else unreachable;
20472067 defer di_nw.deinit();
2048 dwarf.genDeclTypeInner(pt, &di_nw, ni, decl) catch |err| switch (err) {
2068 dwarf.genDeclTypeInner(pt, &di_nw, global, decl) catch |err| switch (err) {
20492069 error.WriteFailed => return dwarf.reportWriteError(&di_nw),
20502070 else => |e| return e,
20512071 };
......@@ -2054,30 +2074,38 @@ fn genDeclTypeInner(
20542074 dwarf: *Dwarf,
20552075 pt: Zcu.PerThread,
20562076 di_nw: *link.MappedFile.Node.Writer,
2057 ni: InternPool.Nav.Index,
2077 global: InternPool.Nav.Index,
20582078 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
20592079) link.EmitError!void {
2060 const ip = &pt.zcu.intern_pool;
2061 const nav = ip.getNav(ni);
2062 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(nav.analysis.?.namespace).owner_type);
2080 const zcu = pt.zcu;
2081 const ip = &zcu.intern_pool;
2082 const nav = ip.getNav(global);
2083 const parent_ty = ip.namespacePtr(nav.analysis.?.namespace).owner_type;
20632084 const di_w = &di_nw.interface;
2064 try dwarf.abbrevCode(di_nw, .decl_type);
2065 try dwarf.secOffset(di_nw, parent_ni, 0);
2066 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2067 try di_w.writeUleb128(decl.src_column + 1);
2068 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2069 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));
2085 if (Type.fromInterned(parent_ty).getCaptures(zcu).len > 0) {
2086 try dwarf.abbrevCode(di_nw, .decl_instance_type);
2087 try dwarf.refType(pt, di_nw, .fromInterned(parent_ty));
2088 try dwarf.secOffset(di_nw, try dwarf.getGlobalDecl(pt, global), 0);
2089 } else {
2090 const parent_ni = try dwarf.getConstDecl(pt, parent_ty);
2091 try dwarf.abbrevCode(di_nw, .decl_type);
2092 try dwarf.secOffset(di_nw, parent_ni, 0);
2093 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2094 try di_w.writeUleb128(decl.src_column + 1);
2095 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2096 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));
2097 }
20702098 try dwarf.refConst(pt, di_nw, .fromInterned(nav.resolved.?.value));
20712099 try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen());
20722100}
20732101
2074fn genDeclValue(
2102fn genDeclGlobal(
20752103 dwarf: *Dwarf,
20762104 pt: Zcu.PerThread,
2077 ni: InternPool.Nav.Index,
2105 global: InternPool.Nav.Index,
20782106 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
20792107) link.Error!void {
2080 const gi = try dwarf.getGlobal(ni);
2108 const gi = try dwarf.getGlobal(global);
20812109 const debug_info_ni = gi.get(dwarf).debug_info_ni.unwrap().?;
20822110 var di_nw: link.MappedFile.Node.Writer = undefined;
20832111 if (dwarf.lf.cast(.elf2)) |elf| {
......@@ -2085,21 +2113,21 @@ fn genDeclValue(
20852113 elf.resetNodeRelocs(debug_info_ni);
20862114 } else unreachable;
20872115 defer di_nw.deinit();
2088 dwarf.genDeclValueInner(pt, &di_nw, ni, decl) catch |err| switch (err) {
2116 dwarf.genDeclGlobalInner(pt, &di_nw, global, decl) catch |err| switch (err) {
20892117 error.WriteFailed => return dwarf.reportWriteError(&di_nw),
20902118 else => |e| return e,
20912119 };
20922120}
2093fn genDeclValueInner(
2121fn genDeclGlobalInner(
20942122 dwarf: *Dwarf,
20952123 pt: Zcu.PerThread,
20962124 di_nw: *link.MappedFile.Node.Writer,
2097 ni: InternPool.Nav.Index,
2125 global: InternPool.Nav.Index,
20982126 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
20992127) link.EmitError!void {
21002128 const zcu = pt.zcu;
21012129 const ip = &zcu.intern_pool;
2102 const nav = ip.getNav(ni);
2130 const nav = ip.getNav(global);
21032131 const nav_const, const nav_ty: Type, const nav_align, const nav_val: Value = resolved: {
21042132 const resolved = nav.resolved.?;
21052133 break :resolved .{
......@@ -2110,7 +2138,7 @@ fn genDeclValueInner(
21102138 };
21112139 };
21122140 const nav_class = nav_ty.classify(zcu);
2113 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(nav.analysis.?.namespace).owner_type);
2141 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(nav.analysis.?.namespace).owner_type);
21142142 const di_w = &di_nw.interface;
21152143 try dwarf.abbrevCode(di_nw, if (nav_const) switch (nav_class) {
21162144 .no_possible_value, .one_possible_value => .decl_const,
......@@ -2589,12 +2617,13 @@ fn updateConstInner(
25892617 .auto, .@"extern" => .decl_instance_empty_struct,
25902618 .@"packed" => .decl_instance_empty_packed_struct,
25912619 });
2592 try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0);
2620 try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, val), 0);
25932621 } else if (loaded_struct.name_nav.unwrap()) |name_ni| {
25942622 const name_nav = ip.getNav(name_ni);
25952623 const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
2596 const parent_ni =
2597 try dwarf.getDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type);
2624 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
2625 name_nav.analysis.?.namespace,
2626 ).owner_type);
25982627 try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0)
25992628 switch (loaded_struct.layout) {
26002629 .auto, .@"extern" => .decl_struct,
......@@ -2611,7 +2640,7 @@ fn updateConstInner(
26112640 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));
26122641 } else {
26132642 const decl = zf.zir.?.getStructDecl(src_inst.inst);
2614 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
2643 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
26152644 ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?,
26162645 ).owner_type);
26172646 try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0)
......@@ -2721,12 +2750,13 @@ fn updateConstInner(
27212750 .auto, .@"extern" => .decl_instance_empty_union,
27222751 .@"packed" => .decl_instance_empty_packed_union,
27232752 });
2724 try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0);
2753 try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, val), 0);
27252754 } else if (loaded_union.name_nav.unwrap()) |name_ni| {
27262755 const name_nav = ip.getNav(name_ni);
27272756 const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
2728 const parent_ni =
2729 try dwarf.getDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type);
2757 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
2758 name_nav.analysis.?.namespace,
2759 ).owner_type);
27302760 try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0)
27312761 switch (loaded_union.layout) {
27322762 .auto, .@"extern" => .decl_union,
......@@ -2743,7 +2773,7 @@ fn updateConstInner(
27432773 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));
27442774 } else {
27452775 const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?);
2746 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
2776 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
27472777 ip.namespacePtr(loaded_union.namespace).parent.unwrap().?,
27482778 ).owner_type);
27492779 try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0)
......@@ -2853,11 +2883,11 @@ fn updateConstInner(
28532883 .decl_instance_enum
28542884 else
28552885 .decl_instance_empty_enum);
2856 try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0);
2886 try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, val), 0);
28572887 } else if (loaded_enum.name_nav.unwrap()) |name_ni| {
28582888 const name_nav = ip.getNav(name_ni);
28592889 const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
2860 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
2890 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
28612891 name_nav.analysis.?.namespace,
28622892 ).owner_type);
28632893 try dwarf.abbrevCode(
......@@ -2871,7 +2901,7 @@ fn updateConstInner(
28712901 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));
28722902 } else {
28732903 const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?);
2874 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
2904 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
28752905 ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?,
28762906 ).owner_type);
28772907 try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0)
......@@ -3036,8 +3066,7 @@ fn updateConstInner(
30363066 const func_type = ip.indexToKey(func.ty).func_type;
30373067 const nav = ip.getNav(func.owner_nav);
30383068 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
3039 const zf = zcu.fileByIndex(inst_info.file);
3040 const zir = &zf.zir.?;
3069 const zir = &zcu.fileByIndex(inst_info.file).zir.?;
30413070 const decl = zir.getDeclaration(inst_info.inst);
30423071 const empty = func_type.param_types.len == 0 and !func_type.is_var_args;
30433072 const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type);
......@@ -3268,12 +3297,12 @@ fn updateConstIncompleteInner(
32683297 .@"union" => .decl_instance_empty_incomplete_union,
32693298 .@"enum" => .decl_instance_empty_incomplete_enum,
32703299 });
3271 try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0);
3300 try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, val), 0);
32723301 } else if (maybe_name_nav.unwrap()) |name_ni| {
32733302 const name_nav = ip.getNav(name_ni);
32743303 const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
32753304 const parent_ni =
3276 try dwarf.getDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type);
3305 try dwarf.getConstDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type);
32773306 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
32783307 .@"struct" => .decl_incomplete_struct,
32793308 .@"union" => .decl_incomplete_union,
......@@ -3289,7 +3318,7 @@ fn updateConstIncompleteInner(
32893318 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
32903319 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));
32913320 } else {
3292 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
3321 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
32933322 ip.namespacePtr(namespace).parent.unwrap().?,
32943323 ).owner_type);
32953324 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
......@@ -3360,10 +3389,16 @@ pub fn genDecl(
33603389 dwarf: *Dwarf,
33613390 pt: Zcu.PerThread,
33623391 di_nw: *link.MappedFile.Node.Writer,
3363 instance_val: InternPool.Index,
3392 instance: Decl.Instance,
33643393) link.Error!void {
3365 log.debug("genDecl({f})", .{Value.fromInterned(instance_val).fmtValue(pt)});
3366 dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) {
3394 switch (instance) {
3395 .none => unreachable,
3396 .@"const" => |@"const"| log.debug("genDecl({f})", .{Value.fromInterned(@"const").fmtValue(pt)}),
3397 .global => |global| log.debug("genDecl({f})", .{
3398 pt.zcu.intern_pool.getNav(global).fqn.fmt(&pt.zcu.intern_pool),
3399 }),
3400 }
3401 dwarf.genDeclInner(pt, di_nw, instance) catch |err| switch (err) {
33673402 else => |e| return e,
33683403 error.WriteFailed => return dwarf.reportWriteError(di_nw),
33693404 };
......@@ -3372,218 +3407,239 @@ fn genDeclInner(
33723407 dwarf: *Dwarf,
33733408 pt: Zcu.PerThread,
33743409 di_nw: *link.MappedFile.Node.Writer,
3375 instance_val: InternPool.Index,
3410 instance: Decl.Instance,
33763411) link.EmitError!void {
33773412 const zcu = pt.zcu;
33783413 const ip = &zcu.intern_pool;
33793414 const di_w = &di_nw.interface;
3380 done: {
3381 const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance_val)) {
3382 else => unreachable,
3383 .struct_type => {
3384 const loaded_struct = ip.loadStructType(instance_val);
3385 const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse {
3386 try dwarf.lostTracking(di_nw);
3387 break :done;
3388 };
3389 const zf = zcu.fileByIndex(src_inst.file);
3390 const zir = &zf.zir.?;
3391 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3392 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
3393 else => unreachable,
3394 .struct_init, .struct_init_ref => {
3395 const decl = zir.extraData(
3396 std.zig.Zir.Inst.StructInit,
3397 inst.data.pl_node.payload_index,
3398 ).data;
3399 break :decl .{ decl.src_line, decl.src_column, &.{} };
3400 },
3401 .struct_init_anon => {
3402 const decl = zir.extraData(
3403 std.zig.Zir.Inst.StructInitAnon,
3404 inst.data.pl_node.payload_index,
3405 ).data;
3406 break :decl .{ decl.src_line, decl.src_column, &.{} };
3407 },
3408 .extended => switch (inst.data.extended.opcode) {
3415 done: switch (instance) {
3416 .none => unreachable,
3417 .@"const" => |@"const"| {
3418 const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance.@"const")) {
3419 else => unreachable,
3420 .struct_type => {
3421 const loaded_struct = ip.loadStructType(@"const");
3422 const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse {
3423 try dwarf.lostTracking(di_nw);
3424 break :done;
3425 };
3426 const zf = zcu.fileByIndex(src_inst.file);
3427 const zir = &zf.zir.?;
3428 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3429 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
34093430 else => unreachable,
3410 .struct_decl => {
3411 const decl = zir.getStructDecl(src_inst.inst);
3412 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3413 },
3414 .reify_struct => {
3431 .struct_init, .struct_init_ref => {
34153432 const decl = zir.extraData(
3416 std.zig.Zir.Inst.ReifyStruct,
3417 inst.data.extended.operand,
3433 std.zig.Zir.Inst.StructInit,
3434 inst.data.pl_node.payload_index,
34183435 ).data;
34193436 break :decl .{ decl.src_line, decl.src_column, &.{} };
34203437 },
3421 },
3422 };
3423 break :container .{
3424 .@"struct",
3425 zf,
3426 src_line,
3427 src_column,
3428 capture_names,
3429 loaded_struct.captures,
3430 loaded_struct.name,
3431 loaded_struct.name_nav,
3432 loaded_struct.namespace,
3433 };
3434 },
3435 .union_type => {
3436 const loaded_union = ip.loadUnionType(instance_val);
3437 const src_inst = loaded_union.zir_index.resolveFull(ip) orelse {
3438 try dwarf.lostTracking(di_nw);
3439 break :done;
3440 };
3441 const zf = zcu.fileByIndex(src_inst.file);
3442 const zir = &zf.zir.?;
3443 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3444 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
3445 else => unreachable,
3446 .extended => switch (inst.data.extended.opcode) {
3447 else => unreachable,
3448 .union_decl => {
3449 const decl = zir.getUnionDecl(src_inst.inst);
3450 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3451 },
3452 .reify_union => {
3438 .struct_init_anon => {
34533439 const decl = zir.extraData(
3454 std.zig.Zir.Inst.ReifyUnion,
3455 inst.data.extended.operand,
3440 std.zig.Zir.Inst.StructInitAnon,
3441 inst.data.pl_node.payload_index,
34563442 ).data;
34573443 break :decl .{ decl.src_line, decl.src_column, &.{} };
34583444 },
3459 },
3460 };
3461 break :container .{
3462 .@"union",
3463 zf,
3464 src_line,
3465 src_column,
3466 capture_names,
3467 loaded_union.captures,
3468 loaded_union.name,
3469 loaded_union.name_nav,
3470 loaded_union.namespace,
3471 };
3472 },
3473 .enum_type => {
3474 const loaded_enum = ip.loadEnumType(instance_val);
3475 const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse {
3476 try dwarf.lostTracking(di_nw);
3477 break :done;
3478 };
3479 const zf = zcu.fileByIndex(src_inst.file);
3480 const zir = &zf.zir.?;
3481 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3482 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
3483 else => unreachable,
3484 .extended => switch (inst.data.extended.opcode) {
3445 .extended => switch (inst.data.extended.opcode) {
3446 else => unreachable,
3447 .struct_decl => {
3448 const decl = zir.getStructDecl(src_inst.inst);
3449 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3450 },
3451 .reify_struct => {
3452 const decl = zir.extraData(
3453 std.zig.Zir.Inst.ReifyStruct,
3454 inst.data.extended.operand,
3455 ).data;
3456 break :decl .{ decl.src_line, decl.src_column, &.{} };
3457 },
3458 },
3459 };
3460 break :container .{
3461 .@"struct",
3462 zf,
3463 src_line,
3464 src_column,
3465 capture_names,
3466 loaded_struct.captures,
3467 loaded_struct.name,
3468 loaded_struct.name_nav,
3469 loaded_struct.namespace,
3470 };
3471 },
3472 .union_type => {
3473 const loaded_union = ip.loadUnionType(@"const");
3474 const src_inst = loaded_union.zir_index.resolveFull(ip) orelse {
3475 try dwarf.lostTracking(di_nw);
3476 break :done;
3477 };
3478 const zf = zcu.fileByIndex(src_inst.file);
3479 const zir = &zf.zir.?;
3480 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3481 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
34853482 else => unreachable,
3486 .enum_decl => {
3487 const decl = zir.getEnumDecl(src_inst.inst);
3488 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3483 .extended => switch (inst.data.extended.opcode) {
3484 else => unreachable,
3485 .union_decl => {
3486 const decl = zir.getUnionDecl(src_inst.inst);
3487 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3488 },
3489 .reify_union => {
3490 const decl = zir.extraData(
3491 std.zig.Zir.Inst.ReifyUnion,
3492 inst.data.extended.operand,
3493 ).data;
3494 break :decl .{ decl.src_line, decl.src_column, &.{} };
3495 },
34893496 },
3490 .reify_enum => {
3491 const decl = zir.extraData(
3492 std.zig.Zir.Inst.ReifyEnum,
3493 inst.data.extended.operand,
3494 ).data;
3495 break :decl .{ decl.src_line, decl.src_column, &.{} };
3497 };
3498 break :container .{
3499 .@"union",
3500 zf,
3501 src_line,
3502 src_column,
3503 capture_names,
3504 loaded_union.captures,
3505 loaded_union.name,
3506 loaded_union.name_nav,
3507 loaded_union.namespace,
3508 };
3509 },
3510 .enum_type => {
3511 const loaded_enum = ip.loadEnumType(@"const");
3512 const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse {
3513 try dwarf.lostTracking(di_nw);
3514 break :done;
3515 };
3516 const zf = zcu.fileByIndex(src_inst.file);
3517 const zir = &zf.zir.?;
3518 const inst = zir.instructions.get(@backingInt(src_inst.inst));
3519 const src_line, const src_column, const capture_names = decl: switch (inst.tag) {
3520 else => unreachable,
3521 .extended => switch (inst.data.extended.opcode) {
3522 else => unreachable,
3523 .enum_decl => {
3524 const decl = zir.getEnumDecl(src_inst.inst);
3525 break :decl .{ decl.src_line, decl.src_column, decl.capture_names };
3526 },
3527 .reify_enum => {
3528 const decl = zir.extraData(
3529 std.zig.Zir.Inst.ReifyEnum,
3530 inst.data.extended.operand,
3531 ).data;
3532 break :decl .{ decl.src_line, decl.src_column, &.{} };
3533 },
34963534 },
3535 };
3536 break :container .{
3537 .@"enum",
3538 zf,
3539 src_line,
3540 src_column,
3541 capture_names,
3542 loaded_enum.captures,
3543 loaded_enum.name,
3544 loaded_enum.name_nav,
3545 loaded_enum.namespace,
3546 };
3547 },
3548 .opaque_type => {
3549 const loaded_opaque = ip.loadOpaqueType(@"const");
3550 const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse {
3551 try dwarf.lostTracking(di_nw);
3552 break :done;
3553 };
3554 const zf = zcu.fileByIndex(src_inst.file);
3555 const decl = zf.zir.?.getOpaqueDecl(src_inst.inst);
3556 break :container .{
3557 .@"struct",
3558 zf,
3559 decl.src_line,
3560 decl.src_column,
3561 decl.capture_names,
3562 loaded_opaque.captures,
3563 loaded_opaque.name,
3564 loaded_opaque.name_nav,
3565 loaded_opaque.namespace,
3566 };
3567 },
3568 };
3569 const zir = &zf.zir.?;
3570 if (maybe_name_nav.unwrap()) |name_ni| {
3571 const name_nav = ip.getNav(name_ni);
3572 const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
3573 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
3574 name_nav.analysis.?.namespace,
3575 ).owner_type);
3576 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
3577 .@"struct" => .decl_specification_struct,
3578 .@"union" => .decl_specification_union,
3579 .@"enum" => .decl_specification_enum,
3580 } else switch (kind) {
3581 .@"struct" => .decl_specification_empty_struct,
3582 .@"union" => .decl_specification_empty_union,
3583 .@"enum" => .decl_specification_empty_enum,
3584 });
3585 try dwarf.secOffset(di_nw, parent_ni, 0);
3586 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
3587 try di_w.writeUleb128(decl.src_column + 1);
3588 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
3589 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));
3590 } else {
3591 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
3592 ip.namespacePtr(namespace).parent.unwrap().?,
3593 ).owner_type);
3594 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
3595 .@"struct" => .type_decl_specification_struct,
3596 .@"union" => .type_decl_specification_union,
3597 .@"enum" => .type_decl_specification_enum,
3598 } else switch (kind) {
3599 .@"struct" => .type_decl_specification_empty_struct,
3600 .@"union" => .type_decl_specification_empty_union,
3601 .@"enum" => .type_decl_specification_empty_enum,
3602 });
3603 try dwarf.secOffset(di_nw, parent_ni, 0);
3604 try di_w.writeInt(u32, src_line + 1, dwarf.endian);
3605 try di_w.writeUleb128(src_column + 1);
3606 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));
3607 }
3608 for (capture_names, captures.get(ip)) |capture_name, capture| {
3609 try dwarf.abbrevCode(di_nw, .capture_specification);
3610 switch (capture.unwrap()) {
3611 .@"comptime", .runtime, .nav_val => try dwarf.strp(
3612 &dwarf.debug_str,
3613 di_nw,
3614 zir.nullTerminatedString(capture_name),
3615 ),
3616 .nav_ref => {
3617 const capture_name_slice =
3618 try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)});
3619 defer zcu.gpa.free(capture_name_slice);
3620 try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice);
34973621 },
3498 };
3499 break :container .{
3500 .@"enum",
3501 zf,
3502 src_line,
3503 src_column,
3504 capture_names,
3505 loaded_enum.captures,
3506 loaded_enum.name,
3507 loaded_enum.name_nav,
3508 loaded_enum.namespace,
3509 };
3510 },
3511 .opaque_type => {
3512 const loaded_opaque = ip.loadOpaqueType(instance_val);
3513 const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse {
3514 try dwarf.lostTracking(di_nw);
3515 break :done;
3516 };
3517 const zf = zcu.fileByIndex(src_inst.file);
3518 const decl = zf.zir.?.getOpaqueDecl(src_inst.inst);
3519 break :container .{
3520 .@"struct",
3521 zf,
3522 decl.src_line,
3523 decl.src_column,
3524 decl.capture_names,
3525 loaded_opaque.captures,
3526 loaded_opaque.name,
3527 loaded_opaque.name_nav,
3528 loaded_opaque.namespace,
3529 };
3530 },
3531 };
3532 const zir = &zf.zir.?;
3533 if (maybe_name_nav.unwrap()) |name_ni| {
3534 const name_nav = ip.getNav(name_ni);
3535 const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?);
3536 const parent_ni =
3537 try dwarf.getDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type);
3538 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
3539 .@"struct" => .decl_specification_struct,
3540 .@"union" => .decl_specification_union,
3541 .@"enum" => .decl_specification_enum,
3542 } else switch (kind) {
3543 .@"struct" => .decl_specification_empty_struct,
3544 .@"union" => .decl_specification_empty_union,
3545 .@"enum" => .decl_specification_empty_enum,
3546 });
3622 }
3623 }
3624 if (captures.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));
3625 },
3626 .global => |global| {
3627 const nav = ip.getNav(global);
3628 const src_inst = nav.srcInst(ip).resolveFull(ip).?;
3629 const decl = zcu.fileByIndex(src_inst.file).zir.?.getDeclaration(src_inst.inst);
3630 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
3631 nav.analysis.?.namespace,
3632 ).owner_type);
3633 try dwarf.abbrevCode(di_nw, if (nav.resolved.?.@"const") switch (nav.resolved.?.type) {
3634 .type_type => .decl_specification_type,
3635 else => .decl_specification_const,
3636 } else .decl_specification_var);
35473637 try dwarf.secOffset(di_nw, parent_ni, 0);
35483638 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
35493639 try di_w.writeUleb128(decl.src_column + 1);
35503640 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
3551 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));
3552 } else {
3553 const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr(
3554 ip.namespacePtr(namespace).parent.unwrap().?,
3555 ).owner_type);
3556 try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) {
3557 .@"struct" => .type_decl_specification_struct,
3558 .@"union" => .type_decl_specification_union,
3559 .@"enum" => .type_decl_specification_enum,
3560 } else switch (kind) {
3561 .@"struct" => .type_decl_specification_empty_struct,
3562 .@"union" => .type_decl_specification_empty_union,
3563 .@"enum" => .type_decl_specification_empty_enum,
3564 });
3565 try dwarf.secOffset(di_nw, parent_ni, 0);
3566 try di_w.writeInt(u32, src_line + 1, dwarf.endian);
3567 try di_w.writeUleb128(src_column + 1);
3568 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));
3569 }
3570 for (capture_names, captures.get(ip)) |capture_name, capture| {
3571 try dwarf.abbrevCode(di_nw, .capture_specification);
3572 switch (capture.unwrap()) {
3573 .@"comptime", .runtime, .nav_val => try dwarf.strp(
3574 &dwarf.debug_str,
3575 di_nw,
3576 zir.nullTerminatedString(capture_name),
3577 ),
3578 .nav_ref => {
3579 const capture_name_slice =
3580 try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)});
3581 defer zcu.gpa.free(capture_name_slice);
3582 try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice);
3583 },
3584 }
3585 }
3586 if (captures.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));
3641 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));
3642 },
35873643 }
35883644 try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen());
35893645}
......@@ -3887,7 +3943,6 @@ pub const AbbrevCode = enum {
38873943 pad_n,
38883944 // decl, specification, and instance codes are assumed to all have the same uleb128 size
38893945 decl_lost,
3890 decl_type,
38913946 decl_empty_incomplete_enum,
38923947 decl_incomplete_enum,
38933948 decl_empty_enum,
......@@ -3920,11 +3975,12 @@ pub const AbbrevCode = enum {
39203975 decl_packed_union,
39213976 type_decl_empty_packed_union,
39223977 type_decl_packed_union,
3923 decl_var,
3978 decl_type,
39243979 decl_const,
39253980 decl_const_fully_runtime,
39263981 decl_const_partially_comptime,
39273982 decl_const_fully_comptime,
3983 decl_var,
39283984 decl_empty_func,
39293985 decl_func,
39303986 decl_empty_func_generic,
......@@ -3943,6 +3999,9 @@ pub const AbbrevCode = enum {
39433999 decl_specification_union,
39444000 type_decl_specification_empty_union,
39454001 type_decl_specification_union,
4002 decl_specification_type,
4003 decl_specification_const,
4004 decl_specification_var,
39464005 decl_specification_func,
39474006 decl_instance_type,
39484007 decl_instance_empty_incomplete_enum,
......@@ -4063,7 +4122,7 @@ pub const AbbrevCode = enum {
40634122 comptime {
40644123 assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1);
40654124 assert(uleb128Size(@backingInt(AbbrevCode.pad_n)) == 1);
4066 assert(uleb128Size(@backingInt(AbbrevCode.decl_type)) == decl_size);
4125 assert(uleb128Size(@backingInt(AbbrevCode.decl_lost)) == decl_size);
40674126 }
40684127
40694128 const Attr = struct {
......@@ -4111,12 +4170,6 @@ pub const AbbrevCode = enum {
41114170 .decl_lost = .{
41124171 .tag = .ZIG_lost_declaration,
41134172 },
4114 .decl_type = .{
4115 .tag = .imported_declaration,
4116 .attrs = decl_attrs ++ .{
4117 .{ .import, .ref_addr },
4118 },
4119 },
41204173 .decl_empty_incomplete_enum = .{
41214174 .tag = .enumeration_type,
41224175 .attrs = decl_attrs,
......@@ -4309,6 +4362,12 @@ pub const AbbrevCode = enum {
43094362 .{ .type, .ref_addr },
43104363 },
43114364 },
4365 .decl_type = .{
4366 .tag = .imported_declaration,
4367 .attrs = decl_attrs ++ .{
4368 .{ .import, .ref_addr },
4369 },
4370 },
43124371 .decl_var = .{
43134372 .tag = .variable,
43144373 .attrs = decl_attrs ++ .{
......@@ -4472,13 +4531,27 @@ pub const AbbrevCode = enum {
44724531 .children = true,
44734532 .attrs = type_decl_specification_attrs,
44744533 },
4534 .decl_specification_type = .{
4535 .tag = .imported_declaration,
4536 .attrs = decl_specification_attrs,
4537 },
4538 .decl_specification_const = .{
4539 .tag = .constant,
4540 .attrs = decl_specification_attrs,
4541 },
4542 .decl_specification_var = .{
4543 .tag = .variable,
4544 .attrs = decl_specification_attrs,
4545 },
44754546 .decl_specification_func = .{
44764547 .tag = .subprogram,
44774548 .attrs = decl_specification_attrs,
44784549 },
44794550 .decl_instance_type = .{
44804551 .tag = .imported_declaration,
4481 .attrs = decl_instance_attrs ++ .{
4552 .attrs = .{
4553 .{ .ZIG_parent, .ref_addr },
4554 } ++ decl_instance_attrs ++ .{
44824555 .{ .import, .ref_addr },
44834556 },
44844557 },
src/link/Elf2.zig+4-4
......@@ -8663,7 +8663,7 @@ fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index)
86638663 } else {
86648664 if (elf.ehdrMachine() != .X86_64) return;
86658665 const mod = zcu.fileByIndex(nav.srcInst(ip).resolveFile(ip)).mod.?;
8666 if (!mod.strip) try elf.dwarf.updateComptimeNav(pt, nav_index);
8666 if (!mod.strip) try elf.dwarf.updateComptimeGlobal(pt, nav_index);
86678667 }
86688668
86698669 // The NAV's node is done---now generate any UAVs or lazy code/data which the NAV needs.
......@@ -9446,15 +9446,15 @@ fn genPending(elf: *Elf, pt: Zcu.PerThread) link.Error!void {
94469446 const gpa = elf.base.comp.gpa;
94479447 while (true) {
94489448 const pending = elf.dwarf.pending_decl;
9449 if (pending.instance_val == .none) break;
9450 elf.dwarf.pending_decl = .{ .di = undefined, .instance_val = .none };
9449 if (pending.instance == .none) break;
9450 elf.dwarf.pending_decl = .{ .di = undefined, .instance = .none };
94519451 const debug_info_ni = pending.di.get(&elf.dwarf).debug_info_ni.unwrap().?;
94529452 try debug_info_ni.moved(gpa, &elf.mf);
94539453 var di_nw: MappedFile.Node.Writer = undefined;
94549454 debug_info_ni.writer(gpa, &elf.mf, &di_nw);
94559455 defer di_nw.deinit();
94569456 elf.resetNodeRelocs(debug_info_ni);
9457 try elf.dwarf.genDecl(pt, &di_nw, pending.instance_val);
9457 try elf.dwarf.genDecl(pt, &di_nw, pending.instance);
94589458 }
94599459 },
94609460 .code_view => unreachable,
src/print_zir.zig+2-1
......@@ -2211,6 +2211,8 @@ const Writer = struct {
22112211 defer self.parent_decl_node = prev_parent_decl_node;
22122212 self.parent_decl_node = decl.src_node;
22132213
2214 try stream.print(":{d}:{d} ", .{ decl.src_line + 1, decl.src_column + 1 });
2215
22142216 if (decl.is_pub) try stream.writeAll("pub ");
22152217 switch (decl.linkage) {
22162218 .normal => {},
......@@ -2224,7 +2226,6 @@ const Writer = struct {
22242226 try stream.print("{s} '{s}'", .{ @tagName(decl.kind), self.code.nullTerminatedString(decl.name) });
22252227 },
22262228 }
2227 try stream.print(":{d}:{d}", .{ decl.src_line + 1, decl.src_column + 1 });
22282229
22292230 const src_hash = self.code.getAssociatedSrcHash(inst).?;
22302231 try stream.print(" hash({x})", .{&src_hash});