mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
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.
This commit is contained in:
parent
8e0a4ca4b3
commit
e83607f52c
1 changed files with 33 additions and 26 deletions
|
|
@ -2008,9 +2008,9 @@ pub const WipNav = struct {
|
||||||
.decl_const_runtime_bits,
|
.decl_const_runtime_bits,
|
||||||
.decl_const_comptime_state,
|
.decl_const_comptime_state,
|
||||||
.decl_const_runtime_bits_comptime_state,
|
.decl_const_runtime_bits_comptime_state,
|
||||||
.decl_empty_func,
|
.decl_nullary_func,
|
||||||
.decl_func,
|
.decl_func,
|
||||||
.decl_empty_func_generic,
|
.decl_nullary_func_generic,
|
||||||
.decl_func_generic,
|
.decl_func_generic,
|
||||||
=> false,
|
=> false,
|
||||||
.generic_decl_var,
|
.generic_decl_var,
|
||||||
|
|
@ -2626,8 +2626,8 @@ pub fn finishWipNavFunc(
|
||||||
abbrev_code_buf,
|
abbrev_code_buf,
|
||||||
try dwarf.refAbbrevCode(switch (abbrev_code) {
|
try dwarf.refAbbrevCode(switch (abbrev_code) {
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
.decl_func => .decl_empty_func,
|
.decl_func => .decl_nullary_func,
|
||||||
.decl_instance_func => .decl_instance_empty_func,
|
.decl_instance_func => .decl_instance_nullary_func,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -3012,29 +3012,34 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
|
||||||
if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) {
|
if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) {
|
||||||
.null => {},
|
.null => {},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
.decl_empty_func, .decl_func, .decl_instance_empty_func, .decl_instance_func => return,
|
.decl_nullary_func, .decl_func, .decl_instance_nullary_func, .decl_instance_func => return,
|
||||||
.decl_empty_func_generic,
|
.decl_nullary_func_generic,
|
||||||
.decl_func_generic,
|
.decl_func_generic,
|
||||||
.decl_instance_empty_func_generic,
|
.decl_instance_nullary_func_generic,
|
||||||
.decl_instance_func_generic,
|
.decl_instance_func_generic,
|
||||||
=> dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(),
|
=> dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(),
|
||||||
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||||
wip_nav.entry = nav_gop.value_ptr.*;
|
wip_nav.entry = nav_gop.value_ptr.*;
|
||||||
|
|
||||||
const func_type = ip.indexToKey(func.ty).func_type;
|
const func_type = ip.indexToKey(func.ty).func_type;
|
||||||
|
const is_nullary = !func_type.is_var_args and for (0..func_type.param_types.len) |param_index| {
|
||||||
|
if (!func_type.paramIsComptime(std.math.cast(u5, param_index) orelse break false)) break false;
|
||||||
|
} else true;
|
||||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||||
try wip_nav.declCommon(if (func_type.param_types.len > 0 or func_type.is_var_args) .{
|
try wip_nav.declCommon(if (is_nullary) .{
|
||||||
|
.decl = .decl_nullary_func_generic,
|
||||||
|
.generic_decl = .generic_decl_func,
|
||||||
|
.decl_instance = .decl_instance_nullary_func_generic,
|
||||||
|
} else .{
|
||||||
.decl = .decl_func_generic,
|
.decl = .decl_func_generic,
|
||||||
.generic_decl = .generic_decl_func,
|
.generic_decl = .generic_decl_func,
|
||||||
.decl_instance = .decl_instance_func_generic,
|
.decl_instance = .decl_instance_func_generic,
|
||||||
} else .{
|
|
||||||
.decl = .decl_empty_func_generic,
|
|
||||||
.generic_decl = .generic_decl_func,
|
|
||||||
.decl_instance = .decl_instance_empty_func_generic,
|
|
||||||
}, &nav, inst_info.file, &decl);
|
}, &nav, inst_info.file, &decl);
|
||||||
try wip_nav.refType(.fromInterned(func_type.return_type));
|
try wip_nav.refType(.fromInterned(func_type.return_type));
|
||||||
if (func_type.param_types.len > 0 or func_type.is_var_args) {
|
if (!is_nullary) {
|
||||||
for (0..func_type.param_types.len) |param_index| {
|
for (0..func_type.param_types.len) |param_index| {
|
||||||
|
if (std.math.cast(u5, param_index)) |small_param_index|
|
||||||
|
if (func_type.paramIsComptime(small_param_index)) continue;
|
||||||
try wip_nav.abbrevCode(.func_type_param);
|
try wip_nav.abbrevCode(.func_type_param);
|
||||||
try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
|
try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
|
||||||
}
|
}
|
||||||
|
|
@ -3568,12 +3573,14 @@ fn updateLazyType(
|
||||||
};
|
};
|
||||||
try diw.writeByte(@intFromEnum(cc));
|
try diw.writeByte(@intFromEnum(cc));
|
||||||
try wip_nav.refType(.fromInterned(func_type.return_type));
|
try wip_nav.refType(.fromInterned(func_type.return_type));
|
||||||
for (0..func_type.param_types.len) |param_index| {
|
if (!is_nullary) {
|
||||||
try wip_nav.abbrevCode(.func_type_param);
|
for (0..func_type.param_types.len) |param_index| {
|
||||||
try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
|
try wip_nav.abbrevCode(.func_type_param);
|
||||||
|
try wip_nav.refType(.fromInterned(func_type.param_types.get(ip)[param_index]));
|
||||||
|
}
|
||||||
|
if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
|
||||||
|
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
||||||
}
|
}
|
||||||
if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
|
|
||||||
if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
|
||||||
},
|
},
|
||||||
.error_set_type => |error_set_type| {
|
.error_set_type => |error_set_type| {
|
||||||
try wip_nav.abbrevCode(if (error_set_type.names.len == 0) .generated_empty_enum_type else .generated_enum_type);
|
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 {
|
||||||
decl_const_runtime_bits,
|
decl_const_runtime_bits,
|
||||||
decl_const_comptime_state,
|
decl_const_comptime_state,
|
||||||
decl_const_runtime_bits_comptime_state,
|
decl_const_runtime_bits_comptime_state,
|
||||||
decl_empty_func,
|
decl_nullary_func,
|
||||||
decl_func,
|
decl_func,
|
||||||
decl_empty_func_generic,
|
decl_nullary_func_generic,
|
||||||
decl_func_generic,
|
decl_func_generic,
|
||||||
generic_decl_var,
|
generic_decl_var,
|
||||||
generic_decl_const,
|
generic_decl_const,
|
||||||
|
|
@ -4806,9 +4813,9 @@ const AbbrevCode = enum {
|
||||||
decl_instance_const_runtime_bits,
|
decl_instance_const_runtime_bits,
|
||||||
decl_instance_const_comptime_state,
|
decl_instance_const_comptime_state,
|
||||||
decl_instance_const_runtime_bits_comptime_state,
|
decl_instance_const_runtime_bits_comptime_state,
|
||||||
decl_instance_empty_func,
|
decl_instance_nullary_func,
|
||||||
decl_instance_func,
|
decl_instance_func,
|
||||||
decl_instance_empty_func_generic,
|
decl_instance_nullary_func_generic,
|
||||||
decl_instance_func_generic,
|
decl_instance_func_generic,
|
||||||
// the rest are unrestricted other than empty variants must not be longer
|
// the rest are unrestricted other than empty variants must not be longer
|
||||||
// than the non-empty variant, and so should appear first
|
// than the non-empty variant, and so should appear first
|
||||||
|
|
@ -5019,7 +5026,7 @@ const AbbrevCode = enum {
|
||||||
.{ .ZIG_comptime_value, .ref_addr },
|
.{ .ZIG_comptime_value, .ref_addr },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.decl_empty_func = .{
|
.decl_nullary_func = .{
|
||||||
.tag = .subprogram,
|
.tag = .subprogram,
|
||||||
.attrs = decl_abbrev_common_attrs ++ .{
|
.attrs = decl_abbrev_common_attrs ++ .{
|
||||||
.{ .linkage_name, .strp },
|
.{ .linkage_name, .strp },
|
||||||
|
|
@ -5044,7 +5051,7 @@ const AbbrevCode = enum {
|
||||||
.{ .noreturn, .flag },
|
.{ .noreturn, .flag },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.decl_empty_func_generic = .{
|
.decl_nullary_func_generic = .{
|
||||||
.tag = .subprogram,
|
.tag = .subprogram,
|
||||||
.attrs = decl_abbrev_common_attrs ++ .{
|
.attrs = decl_abbrev_common_attrs ++ .{
|
||||||
.{ .type, .ref_addr },
|
.{ .type, .ref_addr },
|
||||||
|
|
@ -5167,7 +5174,7 @@ const AbbrevCode = enum {
|
||||||
.{ .ZIG_comptime_value, .ref_addr },
|
.{ .ZIG_comptime_value, .ref_addr },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.decl_instance_empty_func = .{
|
.decl_instance_nullary_func = .{
|
||||||
.tag = .subprogram,
|
.tag = .subprogram,
|
||||||
.attrs = decl_instance_abbrev_common_attrs ++ .{
|
.attrs = decl_instance_abbrev_common_attrs ++ .{
|
||||||
.{ .linkage_name, .strp },
|
.{ .linkage_name, .strp },
|
||||||
|
|
@ -5192,7 +5199,7 @@ const AbbrevCode = enum {
|
||||||
.{ .noreturn, .flag },
|
.{ .noreturn, .flag },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.decl_instance_empty_func_generic = .{
|
.decl_instance_nullary_func_generic = .{
|
||||||
.tag = .subprogram,
|
.tag = .subprogram,
|
||||||
.attrs = decl_instance_abbrev_common_attrs ++ .{
|
.attrs = decl_instance_abbrev_common_attrs ++ .{
|
||||||
.{ .type, .ref_addr },
|
.{ .type, .ref_addr },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue