From bd2154da3d90daa4520ee7ef69dac42f9049ed92 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 18 Mar 2021 22:48:28 -0700 Subject: stage2: the code is compiling again (with a lot of things commented out) --- src/codegen.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/codegen.zig') diff --git a/src/codegen.zig b/src/codegen.zig index 45d66b2767..6649226426 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -792,8 +792,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } } - fn dbgAdvancePCAndLine(self: *Self, src: usize) InnerError!void { - self.prev_di_src = src; + fn dbgAdvancePCAndLine(self: *Self, abs_byte_off: usize) InnerError!void { + self.prev_di_src = abs_byte_off; self.prev_di_pc = self.code.items.len; switch (self.debug_output) { .dwarf => |dbg_out| { @@ -801,7 +801,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { // lookup table, and changing ir.Inst from storing byte offset to token. Currently // this involves scanning over the source code for newlines // (but only from the previous byte offset to the new one). - const delta_line = std.zig.lineDelta(self.source, self.prev_di_src, src); + const delta_line = std.zig.lineDelta(self.source, self.prev_di_src, abs_byte_off); const delta_pc = self.code.items.len - self.prev_di_pc; // TODO Look into using the DWARF special opcodes to compress this data. It lets you emit // single-byte opcodes that add different numbers to both the PC and the line number @@ -2315,8 +2315,12 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } } - fn genDbgStmt(self: *Self, inst: *ir.Inst.NoOp) !MCValue { - try self.dbgAdvancePCAndLine(inst.base.src); + fn genDbgStmt(self: *Self, inst: *ir.Inst.DbgStmt) !MCValue { + // TODO when reworking tzir memory layout, rework source locations here as + // well to be more efficient, as well as support inlined function calls correctly. + // For now we convert LazySrcLoc to absolute byte offset, to match what the + // existing codegen code expects. + try self.dbgAdvancePCAndLine(inst.byte_offset); assert(inst.base.isUnused()); return MCValue.dead; } -- cgit v1.2.3