| ... | @@ -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 | } |
| 531 | | 528 | |
| 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 { |
| 545 | | 542 | |
| 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 | } |
| 550 | | 547 | |
| 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 | } |
| 555 | | 552 | |
| 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-line | 554 | // 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. Currently | 555 | // lookup table, and changing ir.Inst from storing byte offset to token. Currently |
| 559 | // this involves scanning over the source code for newlines | 556 | // 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 emit | 562 | // 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 number | 563 | // 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 | } |
| 1180 | | 1173 | |
| 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 | } |
| 1185 | | 1178 | |