aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-06-22 00:29:38 +0100
committermlugg <mlugg@mlugg.co.uk>2024-06-26 05:28:03 +0100
commit5b523d04690d8a01cb5d97e4f5a35443cb0cbde8 (patch)
treea7c8c3d8266f103e64b1876a0dca90a5a82b663f /src/codegen
parent3e9ab6aa7b2d90c25cb906d425a148abf9da3dcb (diff)
downloadzig-5b523d04690d8a01cb5d97e4f5a35443cb0cbde8.tar.gz
zig-5b523d04690d8a01cb5d97e4f5a35443cb0cbde8.zip
Zir: make `src_line` absolute for `declaration` instructions
We need special logic for updating line numbers anyway, so it's fine to just use absolute numbers here. This eliminates a field from `Decl`.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig18
-rw-r--r--src/codegen/spirv.zig4
2 files changed, 11 insertions, 11 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 1e29d2cbe5..00cfd4404a 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -1697,7 +1697,7 @@ pub const Object = struct {
const file, const subprogram = if (!wip.strip) debug_info: {
const file = try o.getDebugFile(namespace.file_scope);
- const line_number = decl.src_line + 1;
+ const line_number = decl.navSrcLine(zcu) + 1;
const is_internal_linkage = decl.val.getExternFunc(zcu) == null and
!zcu.decl_exports.contains(decl_index);
const debug_decl_type = try o.lowerDebugType(decl.typeOf(zcu));
@@ -1741,7 +1741,7 @@ pub const Object = struct {
.sync_scope = if (owner_mod.single_threaded) .singlethread else .system,
.file = file,
.scope = subprogram,
- .base_line = dg.decl.src_line,
+ .base_line = dg.decl.navSrcLine(zcu),
.prev_dbg_line = 0,
.prev_dbg_column = 0,
.err_ret_trace = err_ret_trace,
@@ -2067,7 +2067,7 @@ pub const Object = struct {
try o.builder.metadataString(name),
file,
scope,
- owner_decl.src_line + 1, // Line
+ owner_decl.typeSrcLine(mod) + 1, // Line
try o.lowerDebugType(int_ty),
ty.abiSize(mod) * 8,
(ty.abiAlignment(mod).toByteUnits() orelse 0) * 8,
@@ -2237,7 +2237,7 @@ pub const Object = struct {
try o.builder.metadataString(name),
try o.getDebugFile(mod.namespacePtr(owner_decl.src_namespace).file_scope),
try o.namespaceToDebugScope(owner_decl.src_namespace),
- owner_decl.src_line + 1, // Line
+ owner_decl.typeSrcLine(mod) + 1, // Line
.none, // Underlying type
0, // Size
0, // Align
@@ -2867,7 +2867,7 @@ pub const Object = struct {
try o.builder.metadataString(decl.name.toSlice(&mod.intern_pool)), // TODO use fully qualified name
try o.getDebugFile(mod.namespacePtr(decl.src_namespace).file_scope),
try o.namespaceToDebugScope(decl.src_namespace),
- decl.src_line + 1,
+ decl.typeSrcLine(mod) + 1,
.none,
0,
0,
@@ -4762,7 +4762,7 @@ pub const DeclGen = struct {
else => try o.lowerValue(init_val),
}, &o.builder);
- const line_number = decl.src_line + 1;
+ const line_number = decl.navSrcLine(zcu) + 1;
const is_internal_linkage = !o.module.decl_exports.contains(decl_index);
const namespace = zcu.namespacePtr(decl.src_namespace);
@@ -5188,7 +5188,7 @@ pub const FuncGen = struct {
self.file = try o.getDebugFile(namespace.file_scope);
- const line_number = decl.src_line + 1;
+ const line_number = decl.navSrcLine(zcu) + 1;
self.inlined = self.wip.debug_location;
const fqn = try decl.fullyQualifiedName(zcu);
@@ -5217,7 +5217,7 @@ pub const FuncGen = struct {
o.debug_compile_unit,
);
- self.base_line = decl.src_line;
+ self.base_line = decl.navSrcLine(zcu);
const inlined_at_location = try self.wip.debug_location.toMetadata(&o.builder);
self.wip.debug_location = .{
.location = .{
@@ -8857,7 +8857,7 @@ pub const FuncGen = struct {
const src_index = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.src_index;
const func_index = self.dg.decl.getOwnedFunctionIndex();
const func = mod.funcInfo(func_index);
- const lbrace_line = mod.declPtr(func.owner_decl).src_line + func.lbrace_line + 1;
+ const lbrace_line = mod.declPtr(func.owner_decl).navSrcLine(mod) + func.lbrace_line + 1;
const lbrace_col = func.lbrace_column + 1;
const debug_parameter = try o.builder.debugParameter(
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 8168cce996..ee163c3154 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -212,7 +212,7 @@ pub const Object = struct {
false => .{ .unstructured = .{} },
},
.current_block_label = undefined,
- .base_line = decl.src_line,
+ .base_line = decl.navSrcLine(mod),
};
defer decl_gen.deinit();
@@ -6345,7 +6345,7 @@ const DeclGen = struct {
const decl = mod.funcOwnerDeclPtr(extra.data.func);
const old_base_line = self.base_line;
defer self.base_line = old_base_line;
- self.base_line = decl.src_line;
+ self.base_line = decl.navSrcLine(mod);
return self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
}