stage2 codegen: revert the unneeded is_stmt stuff

This commit is contained in:
Andrew Kelley 2020-08-03 21:09:58 -07:00
parent d624bf8059
commit a33efc74ed

View File

@ -225,8 +225,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
prev_di_src: usize,
/// Relative to the beginning of `code`.
prev_di_pc: usize,
/// The is_stmt register value, used to avoid redundant LNS_negate_stmt ops.
prev_di_is_stmt: bool,
/// Used to find newlines and count line deltas.
source: []const u8,
/// Byte offset within the source file of the ending curly.
@ -422,7 +420,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.stack_align = undefined,
.prev_di_pc = 0,
.prev_di_src = lbrace_src,
.prev_di_is_stmt = true,
.rbrace_src = rbrace_src,
.source = tree.source,
};
@ -526,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
},
}
// Drop them off at the rbrace.
try self.dbgAdvancePCAndLine(self.rbrace_src, true);
try self.dbgAdvancePCAndLine(self.rbrace_src);
}
fn genBody(self: *Self, body: ir.Body) InnerError!void {
@ -545,15 +542,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
fn dbgSetPrologueEnd(self: *Self) InnerError!void {
try self.dbg_line.append(DW.LNS_set_prologue_end);
try self.dbgAdvancePCAndLine(self.prev_di_src, true);
try self.dbgAdvancePCAndLine(self.prev_di_src);
}
fn dbgSetEpilogueBegin(self: *Self) InnerError!void {
try self.dbg_line.append(DW.LNS_set_epilogue_begin);
try self.dbgAdvancePCAndLine(self.prev_di_src, true);
try self.dbgAdvancePCAndLine(self.prev_di_src);
}
fn dbgAdvancePCAndLine(self: *Self, src: usize, is_stmt: bool) InnerError!void {
fn dbgAdvancePCAndLine(self: *Self, src: usize) InnerError!void {
// TODO Look into improving the performance here by adding a token-index-to-line
// lookup table, and changing ir.Inst from storing byte offset to token. Currently
// this involves scanning over the source code for newlines
@ -565,11 +562,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
// 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
// at the same time.
try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 12);
if (self.prev_di_is_stmt != is_stmt) {
self.dbg_line.appendAssumeCapacity(DW.LNS_negate_stmt);
self.prev_di_is_stmt = is_stmt;
}
try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 11);
self.dbg_line.appendAssumeCapacity(DW.LNS_advance_pc);
leb128.writeULEB128(self.dbg_line.writer(), delta_pc) catch unreachable;
if (delta_line != 0) {
@ -1179,7 +1172,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
}
fn genDbgStmt(self: *Self, inst: *ir.Inst.NoOp) !MCValue {
try self.dbgAdvancePCAndLine(inst.base.src, true);
try self.dbgAdvancePCAndLine(inst.base.src);
return MCValue.none;
}