authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 21:09:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 21:09:58-07:00
loga33efc74ed303517aa458109acfcd5c40dc97703
tree0981f8203243ba47ee8a082ceb926708f9885205
parentd624bf8059fa3a86a740f40a1ef763756edd91ce

stage2 codegen: revert the unneeded is_stmt stuff


1 files changed, 6 insertions(+), 13 deletions(-)

src-self-hosted/codegen.zig+6-13
...@@ -225,8 +225,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -225,8 +225,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
225 prev_di_src: usize,225 prev_di_src: usize,
226 /// Relative to the beginning of `code`.226 /// Relative to the beginning of `code`.
227 prev_di_pc: usize,227 prev_di_pc: usize,
228 /// The is_stmt register value, used to avoid redundant LNS_negate_stmt ops.
229 prev_di_is_stmt: bool,
230 /// Used to find newlines and count line deltas.228 /// Used to find newlines and count line deltas.
231 source: []const u8,229 source: []const u8,
232 /// Byte offset within the source file of the ending curly.230 /// Byte offset within the source file of the ending curly.
...@@ -422,7 +420,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -422,7 +420,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
422 .stack_align = undefined,420 .stack_align = undefined,
423 .prev_di_pc = 0,421 .prev_di_pc = 0,
424 .prev_di_src = lbrace_src,422 .prev_di_src = lbrace_src,
425 .prev_di_is_stmt = true,
426 .rbrace_src = rbrace_src,423 .rbrace_src = rbrace_src,
427 .source = tree.source,424 .source = tree.source,
428 };425 };
...@@ -526,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -526,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
526 },523 },
527 }524 }
528 // Drop them off at the rbrace.525 // Drop them off at the rbrace.
529 try self.dbgAdvancePCAndLine(self.rbrace_src, true);526 try self.dbgAdvancePCAndLine(self.rbrace_src);
530 }527 }
531528
532 fn genBody(self: *Self, body: ir.Body) InnerError!void {529 fn genBody(self: *Self, body: ir.Body) InnerError!void {
...@@ -545,15 +542,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -545,15 +542,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
545542
546 fn dbgSetPrologueEnd(self: *Self) InnerError!void {543 fn dbgSetPrologueEnd(self: *Self) InnerError!void {
547 try self.dbg_line.append(DW.LNS_set_prologue_end);544 try self.dbg_line.append(DW.LNS_set_prologue_end);
548 try self.dbgAdvancePCAndLine(self.prev_di_src, true);545 try self.dbgAdvancePCAndLine(self.prev_di_src);
549 }546 }
550547
551 fn dbgSetEpilogueBegin(self: *Self) InnerError!void {548 fn dbgSetEpilogueBegin(self: *Self) InnerError!void {
552 try self.dbg_line.append(DW.LNS_set_epilogue_begin);549 try self.dbg_line.append(DW.LNS_set_epilogue_begin);
553 try self.dbgAdvancePCAndLine(self.prev_di_src, true);550 try self.dbgAdvancePCAndLine(self.prev_di_src);
554 }551 }
555552
556 fn dbgAdvancePCAndLine(self: *Self, src: usize, is_stmt: bool) InnerError!void {553 fn dbgAdvancePCAndLine(self: *Self, src: usize) InnerError!void {
557 // TODO Look into improving the performance here by adding a token-index-to-line554 // TODO Look into improving the performance here by adding a token-index-to-line
558 // lookup table, and changing ir.Inst from storing byte offset to token. Currently555 // lookup table, and changing ir.Inst from storing byte offset to token. Currently
559 // this involves scanning over the source code for newlines556 // this involves scanning over the source code for newlines
...@@ -565,11 +562,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -565,11 +562,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
565 // TODO Look into using the DWARF special opcodes to compress this data. It lets you emit562 // TODO Look into using the DWARF special opcodes to compress this data. It lets you emit
566 // single-byte opcodes that add different numbers to both the PC and the line number563 // single-byte opcodes that add different numbers to both the PC and the line number
567 // at the same time.564 // at the same time.
568 try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 12);565 try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 11);
569 if (self.prev_di_is_stmt != is_stmt) {
570 self.dbg_line.appendAssumeCapacity(DW.LNS_negate_stmt);
571 self.prev_di_is_stmt = is_stmt;
572 }
573 self.dbg_line.appendAssumeCapacity(DW.LNS_advance_pc);566 self.dbg_line.appendAssumeCapacity(DW.LNS_advance_pc);
574 leb128.writeULEB128(self.dbg_line.writer(), delta_pc) catch unreachable;567 leb128.writeULEB128(self.dbg_line.writer(), delta_pc) catch unreachable;
575 if (delta_line != 0) {568 if (delta_line != 0) {
...@@ -1179,7 +1172,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1179,7 +1172,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1179 }1172 }
11801173
1181 fn genDbgStmt(self: *Self, inst: *ir.Inst.NoOp) !MCValue {1174 fn genDbgStmt(self: *Self, inst: *ir.Inst.NoOp) !MCValue {
1182 try self.dbgAdvancePCAndLine(inst.base.src, true);1175 try self.dbgAdvancePCAndLine(inst.base.src);
1183 return MCValue.none;1176 return MCValue.none;
1184 }1177 }
11851178