authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-30 08:20:42-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-30 08:21:24-04:00
logf0c0f697a6be87f1e926a03b6a61579cddde08e7
treef9a3f4dd83babcfaa0675a53e08ff16b24e11984
parentd997ddaa102bb9ba5f1e8480b8c78f7d102b5512

Dwarf: fix zir inst index comparison not checking the file


1 files changed, 18 insertions(+), 17 deletions(-)

src/link/Dwarf.zig+18-17
......@@ -2593,6 +2593,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
25932593 decl_struct: {
25942594 if (loaded_struct.zir_index == .none) break :decl_struct;
25952595
2596 const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
2597 if (type_inst_info.file != inst_info.file) break :decl_struct;
2598
25962599 const value_inst = value_inst: {
25972600 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
25982601 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
......@@ -2608,7 +2611,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
26082611 };
26092612 break :value_inst value_inst;
26102613 };
2611 const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
26122614 if (type_inst_info.inst != value_inst) break :decl_struct;
26132615
26142616 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
......@@ -2623,6 +2625,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
26232625 type_gop.value_ptr.* = nav_gop.value_ptr.*;
26242626 }
26252627 wip_nav.entry = nav_gop.value_ptr.*;
2628
26262629 const diw = wip_nav.debug_info.writer(dwarf.gpa);
26272630
26282631 switch (loaded_struct.layout) {
......@@ -2714,6 +2717,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27142717 decl_enum: {
27152718 if (loaded_enum.zir_index == .none) break :decl_enum;
27162719
2720 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
2721 if (type_inst_info.file != inst_info.file) break :decl_enum;
2722
27172723 const value_inst = value_inst: {
27182724 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
27192725 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
......@@ -2729,7 +2735,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27292735 };
27302736 break :value_inst value_inst;
27312737 };
2732 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
27332738 if (type_inst_info.inst != value_inst) break :decl_enum;
27342739
27352740 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
......@@ -2797,6 +2802,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27972802 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
27982803
27992804 decl_union: {
2805 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
2806 if (type_inst_info.file != inst_info.file) break :decl_union;
2807
28002808 const value_inst = value_inst: {
28012809 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
28022810 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
......@@ -2812,7 +2820,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
28122820 };
28132821 break :value_inst value_inst;
28142822 };
2815 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
28162823 if (type_inst_info.inst != value_inst) break :decl_union;
28172824
28182825 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
......@@ -2872,9 +2879,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
28722879 }
28732880 }
28742881 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2875
2876 if (ip.indexToKey(loaded_union.enum_tag_ty).enum_type == .generated_tag)
2877 try wip_nav.pending_types.append(dwarf.gpa, loaded_union.enum_tag_ty);
28782882 } else for (0..loaded_union.field_types.len) |field_index| {
28792883 try wip_nav.abbrevCode(.untagged_union_field);
28802884 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
......@@ -2919,6 +2923,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
29192923 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
29202924
29212925 decl_opaque: {
2926 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
2927 if (type_inst_info.file != inst_info.file) break :decl_opaque;
2928
29222929 const value_inst = value_inst: {
29232930 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
29242931 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
......@@ -2934,7 +2941,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
29342941 };
29352942 break :value_inst value_inst;
29362943 };
2937 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
29382944 if (type_inst_info.inst != value_inst) break :decl_opaque;
29392945
29402946 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
......@@ -3381,14 +3387,12 @@ fn updateType(
33813387 .Kernel, .Fragment, .Vertex => .nocall,
33823388 })));
33833389 try wip_nav.refType(Type.fromInterned(func_type.return_type));
3384 if (!is_nullary) {
3385 for (0..func_type.param_types.len) |param_index| {
3386 try wip_nav.abbrevCode(.func_type_param);
3387 try wip_nav.refType(Type.fromInterned(func_type.param_types.get(ip)[param_index]));
3388 }
3389 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
3390 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3390 for (0..func_type.param_types.len) |param_index| {
3391 try wip_nav.abbrevCode(.func_type_param);
3392 try wip_nav.refType(Type.fromInterned(func_type.param_types.get(ip)[param_index]));
33913393 }
3394 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
3395 if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));
33923396 },
33933397 .error_set_type => |error_set_type| {
33943398 try wip_nav.abbrevCode(if (error_set_type.names.len > 0) .enum_type else .empty_enum_type);
......@@ -3643,9 +3647,6 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
36433647 }
36443648 }
36453649 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3646
3647 if (ip.indexToKey(loaded_union.enum_tag_ty).enum_type == .generated_tag)
3648 try wip_nav.pending_types.append(dwarf.gpa, loaded_union.enum_tag_ty);
36493650 } else for (0..loaded_union.field_types.len) |field_index| {
36503651 try wip_nav.abbrevCode(.untagged_union_field);
36513652 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));