authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-03-10 07:59:18-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-03-10 08:46:00-04:00
loge83607f52c82a2c0ca6887f947228cd447477651
tree75649399b85962f06876b1b65443a102ea580c92
parent8e0a4ca4b34a0222d9261d51c34fba8ce2a1d0bc

Dwarf: remove comptime parameters from generic origin functions

Since generic instantiations are missing comptime arguments in Air, they must be removed from the generic origins too.

1 files changed, 33 insertions(+), 26 deletions(-)

src/link/Dwarf.zig+33-26
...@@ -2008,9 +2008,9 @@ pub const WipNav = struct {...@@ -2008,9 +2008,9 @@ pub const WipNav = struct {
2008 .decl_const_runtime_bits,2008 .decl_const_runtime_bits,
2009 .decl_const_comptime_state,2009 .decl_const_comptime_state,
2010 .decl_const_runtime_bits_comptime_state,2010 .decl_const_runtime_bits_comptime_state,
2011 .decl_empty_func,2011 .decl_nullary_func,
2012 .decl_func,2012 .decl_func,
2013 .decl_empty_func_generic,2013 .decl_nullary_func_generic,
2014 .decl_func_generic,2014 .decl_func_generic,
2015 => false,2015 => false,
2016 .generic_decl_var,2016 .generic_decl_var,
...@@ -2626,8 +2626,8 @@ pub fn finishWipNavFunc(...@@ -2626,8 +2626,8 @@ pub fn finishWipNavFunc(
2626 abbrev_code_buf,2626 abbrev_code_buf,
2627 try dwarf.refAbbrevCode(switch (abbrev_code) {2627 try dwarf.refAbbrevCode(switch (abbrev_code) {
2628 else => unreachable,2628 else => unreachable,
2629 .decl_func => .decl_empty_func,2629 .decl_func => .decl_nullary_func,
2630 .decl_instance_func => .decl_instance_empty_func,2630 .decl_instance_func => .decl_instance_nullary_func,
2631 }),2631 }),
2632 );2632 );
2633 }2633 }
...@@ -3012,29 +3012,34 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo...@@ -3012,29 +3012,34 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
3012 if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) {3012 if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) {
3013 .null => {},3013 .null => {},
3014 else => unreachable,3014 else => unreachable,
3015 .decl_empty_func, .decl_func, .decl_instance_empty_func, .decl_instance_func => return,3015 .decl_nullary_func, .decl_func, .decl_instance_nullary_func, .decl_instance_func => return,
3016 .decl_empty_func_generic,3016 .decl_nullary_func_generic,
3017 .decl_func_generic,3017 .decl_func_generic,
3018 .decl_instance_empty_func_generic,3018 .decl_instance_nullary_func_generic,
3019 .decl_instance_func_generic,3019 .decl_instance_func_generic,
3020 => dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(),3020 => dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(),
3021 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);3021 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
3022 wip_nav.entry = nav_gop.value_ptr.*;3022 wip_nav.entry = nav_gop.value_ptr.*;
30233023
3024 const func_type = ip.indexToKey(func.ty).func_type;3024 const func_type = ip.indexToKey(func.ty).func_type;
3025 const is_nullary = !func_type.is_var_args and for (0..func_type.param_types.len) |param_index| {
3026 if (!func_type.paramIsComptime(std.math.cast(u5, param_index) orelse break false)) break false;
3027 } else true;
3025 const diw = wip_nav.debug_info.writer(dwarf.gpa);3028 const diw = wip_nav.debug_info.writer(dwarf.gpa);
3026 try wip_nav.declCommon(if (func_type.param_types.len > 0 or func_type.is_var_args) .{3029 try wip_nav.declCommon(if (is_nullary) .{
3027 .decl = .decl_func_generic,3030 .decl = .decl_nullary_func_generic,
3028 .generic_decl = .generic_decl_func,3031 .generic_decl = .generic_decl_func,
3029 .decl_instance = .decl_instance_func_generic,3032 .decl_instance = .decl_instance_nullary_func_generic,
3030 } else .{3033 } else .{
3031 .decl = .decl_empty_func_generic,3034 .decl = .decl_func_generic,
3032 .generic_decl = .generic_decl_func,3035 .generic_decl = .generic_decl_func,
3033 .decl_instance = .decl_instance_empty_func_generic,3036 .decl_instance = .decl_instance_func_generic,
3034 }, &nav, inst_info.file, &decl);3037 }, &nav, inst_info.file, &decl);
3035 try wip_nav.refType(.fromInterned(func_type.return_type));3038 try wip_nav.refType(.fromInterned(func_type.return_type));
3036 if (func_type.param_types.len > 0 or func_type.is_var_args) {3039 if (!is_nullary) {
3037 for (0..func_type.param_types.len) |param_index| {3040 for (0..func_type.param_types.len) |param_index| {
3041 if (std.math.cast(u5, param_index)) |small_param_index|
3042 if (func_type.paramIsComptime(small_param_index)) continue;
3038 try wip_nav.abbrevCode(.func_type_param);3043 try wip_nav.abbrevCode(.func_type_param);
3039 try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));3044 try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
3040 }3045 }
...@@ -3568,12 +3573,14 @@ fn updateLazyType(...@@ -3568,12 +3573,14 @@ fn updateLazyType(
3568 };3573 };
3569 try diw.writeByte(@intFromEnum(cc));3574 try diw.writeByte(@intFromEnum(cc));
3570 try wip_nav.refType(.fromInterned(func_type.return_type));3575 try wip_nav.refType(.fromInterned(func_type.return_type));
3571 for (0..func_type.param_types.len) |param_index| {3576 if (!is_nullary) {
3572 try wip_nav.abbrevCode(.func_type_param);3577 for (0..func_type.param_types.len) |param_index| {
3573 try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));3578 try wip_nav.abbrevCode(.func_type_param);
3579 try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
3580 }
3581 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
3582 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3574 }3583 }
3575 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
3576 if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3577 },3584 },
3578 .error_set_type => |error_set_type| {3585 .error_set_type => |error_set_type| {
3579 try wip_nav.abbrevCode(if (error_set_type.names.len == 0) .generated_empty_enum_type else .generated_enum_type);3586 try wip_nav.abbrevCode(if (error_set_type.names.len == 0) .generated_empty_enum_type else .generated_enum_type);
...@@ -4787,9 +4794,9 @@ const AbbrevCode = enum {...@@ -4787,9 +4794,9 @@ const AbbrevCode = enum {
4787 decl_const_runtime_bits,4794 decl_const_runtime_bits,
4788 decl_const_comptime_state,4795 decl_const_comptime_state,
4789 decl_const_runtime_bits_comptime_state,4796 decl_const_runtime_bits_comptime_state,
4790 decl_empty_func,4797 decl_nullary_func,
4791 decl_func,4798 decl_func,
4792 decl_empty_func_generic,4799 decl_nullary_func_generic,
4793 decl_func_generic,4800 decl_func_generic,
4794 generic_decl_var,4801 generic_decl_var,
4795 generic_decl_const,4802 generic_decl_const,
...@@ -4806,9 +4813,9 @@ const AbbrevCode = enum {...@@ -4806,9 +4813,9 @@ const AbbrevCode = enum {
4806 decl_instance_const_runtime_bits,4813 decl_instance_const_runtime_bits,
4807 decl_instance_const_comptime_state,4814 decl_instance_const_comptime_state,
4808 decl_instance_const_runtime_bits_comptime_state,4815 decl_instance_const_runtime_bits_comptime_state,
4809 decl_instance_empty_func,4816 decl_instance_nullary_func,
4810 decl_instance_func,4817 decl_instance_func,
4811 decl_instance_empty_func_generic,4818 decl_instance_nullary_func_generic,
4812 decl_instance_func_generic,4819 decl_instance_func_generic,
4813 // the rest are unrestricted other than empty variants must not be longer4820 // the rest are unrestricted other than empty variants must not be longer
4814 // than the non-empty variant, and so should appear first4821 // than the non-empty variant, and so should appear first
...@@ -5019,7 +5026,7 @@ const AbbrevCode = enum {...@@ -5019,7 +5026,7 @@ const AbbrevCode = enum {
5019 .{ .ZIG_comptime_value, .ref_addr },5026 .{ .ZIG_comptime_value, .ref_addr },
5020 },5027 },
5021 },5028 },
5022 .decl_empty_func = .{5029 .decl_nullary_func = .{
5023 .tag = .subprogram,5030 .tag = .subprogram,
5024 .attrs = decl_abbrev_common_attrs ++ .{5031 .attrs = decl_abbrev_common_attrs ++ .{
5025 .{ .linkage_name, .strp },5032 .{ .linkage_name, .strp },
...@@ -5044,7 +5051,7 @@ const AbbrevCode = enum {...@@ -5044,7 +5051,7 @@ const AbbrevCode = enum {
5044 .{ .noreturn, .flag },5051 .{ .noreturn, .flag },
5045 },5052 },
5046 },5053 },
5047 .decl_empty_func_generic = .{5054 .decl_nullary_func_generic = .{
5048 .tag = .subprogram,5055 .tag = .subprogram,
5049 .attrs = decl_abbrev_common_attrs ++ .{5056 .attrs = decl_abbrev_common_attrs ++ .{
5050 .{ .type, .ref_addr },5057 .{ .type, .ref_addr },
...@@ -5167,7 +5174,7 @@ const AbbrevCode = enum {...@@ -5167,7 +5174,7 @@ const AbbrevCode = enum {
5167 .{ .ZIG_comptime_value, .ref_addr },5174 .{ .ZIG_comptime_value, .ref_addr },
5168 },5175 },
5169 },5176 },
5170 .decl_instance_empty_func = .{5177 .decl_instance_nullary_func = .{
5171 .tag = .subprogram,5178 .tag = .subprogram,
5172 .attrs = decl_instance_abbrev_common_attrs ++ .{5179 .attrs = decl_instance_abbrev_common_attrs ++ .{
5173 .{ .linkage_name, .strp },5180 .{ .linkage_name, .strp },
...@@ -5192,7 +5199,7 @@ const AbbrevCode = enum {...@@ -5192,7 +5199,7 @@ const AbbrevCode = enum {
5192 .{ .noreturn, .flag },5199 .{ .noreturn, .flag },
5193 },5200 },
5194 },5201 },
5195 .decl_instance_empty_func_generic = .{5202 .decl_instance_nullary_func_generic = .{
5196 .tag = .subprogram,5203 .tag = .subprogram,
5197 .attrs = decl_instance_abbrev_common_attrs ++ .{5204 .attrs = decl_instance_abbrev_common_attrs ++ .{
5198 .{ .type, .ref_addr },5205 .{ .type, .ref_addr },