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...@@ -2593,6 +2593,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2593 decl_struct: {2593 decl_struct: {
2594 if (loaded_struct.zir_index == .none) break :decl_struct;2594 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
2596 const value_inst = value_inst: {2599 const value_inst = value_inst: {
2597 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2600 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2598 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2601 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...@@ -2608,7 +2611,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2608 };2611 };
2609 break :value_inst value_inst;2612 break :value_inst value_inst;
2610 };2613 };
2611 const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
2612 if (type_inst_info.inst != value_inst) break :decl_struct;2614 if (type_inst_info.inst != value_inst) break :decl_struct;
26132615
2614 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2616 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...@@ -2623,6 +2625,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2623 type_gop.value_ptr.* = nav_gop.value_ptr.*;2625 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2624 }2626 }
2625 wip_nav.entry = nav_gop.value_ptr.*;2627 wip_nav.entry = nav_gop.value_ptr.*;
2628
2626 const diw = wip_nav.debug_info.writer(dwarf.gpa);2629 const diw = wip_nav.debug_info.writer(dwarf.gpa);
26272630
2628 switch (loaded_struct.layout) {2631 switch (loaded_struct.layout) {
...@@ -2714,6 +2717,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2714,6 +2717,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2714 decl_enum: {2717 decl_enum: {
2715 if (loaded_enum.zir_index == .none) break :decl_enum;2718 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
2717 const value_inst = value_inst: {2723 const value_inst = value_inst: {
2718 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2724 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2719 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2725 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...@@ -2729,7 +2735,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2729 };2735 };
2730 break :value_inst value_inst;2736 break :value_inst value_inst;
2731 };2737 };
2732 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
2733 if (type_inst_info.inst != value_inst) break :decl_enum;2738 if (type_inst_info.inst != value_inst) break :decl_enum;
27342739
2735 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2740 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...@@ -2797,6 +2802,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2797 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };2802 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
27982803
2799 decl_union: {2804 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
2800 const value_inst = value_inst: {2808 const value_inst = value_inst: {
2801 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2809 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2802 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2810 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...@@ -2812,7 +2820,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2812 };2820 };
2813 break :value_inst value_inst;2821 break :value_inst value_inst;
2814 };2822 };
2815 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
2816 if (type_inst_info.inst != value_inst) break :decl_union;2823 if (type_inst_info.inst != value_inst) break :decl_union;
28172824
2818 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2825 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...@@ -2872,9 +2879,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2872 }2879 }
2873 }2880 }
2874 try uleb128(diw, @intFromEnum(AbbrevCode.null));2881 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);
2878 } else for (0..loaded_union.field_types.len) |field_index| {2882 } else for (0..loaded_union.field_types.len) |field_index| {
2879 try wip_nav.abbrevCode(.untagged_union_field);2883 try wip_nav.abbrevCode(.untagged_union_field);
2880 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));2884 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...@@ -2919,6 +2923,9 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2919 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };2923 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
29202924
2921 decl_opaque: {2925 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
2922 const value_inst = value_inst: {2929 const value_inst = value_inst: {
2923 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2930 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2924 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2931 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...@@ -2934,7 +2941,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2934 };2941 };
2935 break :value_inst value_inst;2942 break :value_inst value_inst;
2936 };2943 };
2937 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
2938 if (type_inst_info.inst != value_inst) break :decl_opaque;2944 if (type_inst_info.inst != value_inst) break :decl_opaque;
29392945
2940 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2946 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
...@@ -3381,14 +3387,12 @@ fn updateType(...@@ -3381,14 +3387,12 @@ fn updateType(
3381 .Kernel, .Fragment, .Vertex => .nocall,3387 .Kernel, .Fragment, .Vertex => .nocall,
3382 })));3388 })));
3383 try wip_nav.refType(Type.fromInterned(func_type.return_type));3389 try wip_nav.refType(Type.fromInterned(func_type.return_type));
3384 if (!is_nullary) {3390 for (0..func_type.param_types.len) |param_index| {
3385 for (0..func_type.param_types.len) |param_index| {3391 try wip_nav.abbrevCode(.func_type_param);
3386 try wip_nav.abbrevCode(.func_type_param);3392 try wip_nav.refType(Type.fromInterned(func_type.param_types.get(ip)[param_index]));
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));
3391 }3393 }
3394 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
3395 if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3392 },3396 },
3393 .error_set_type => |error_set_type| {3397 .error_set_type => |error_set_type| {
3394 try wip_nav.abbrevCode(if (error_set_type.names.len > 0) .enum_type else .empty_enum_type);3398 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...@@ -3643,9 +3647,6 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3643 }3647 }
3644 }3648 }
3645 try uleb128(diw, @intFromEnum(AbbrevCode.null));3649 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);
3649 } else for (0..loaded_union.field_types.len) |field_index| {3650 } else for (0..loaded_union.field_types.len) |field_index| {
3650 try wip_nav.abbrevCode(.untagged_union_field);3651 try wip_nav.abbrevCode(.untagged_union_field);
3651 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));3652 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));