| ... | ... | @@ -225,8 +225,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 225 | 225 | prev_di_src: usize, |
| 226 | 226 | /// Relative to the beginning of `code`. |
| 227 | 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 | 228 | /// Used to find newlines and count line deltas. |
| 231 | 229 | source: []const u8, |
| 232 | 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 | 420 | .stack_align = undefined, |
| 423 | 421 | .prev_di_pc = 0, |
| 424 | 422 | .prev_di_src = lbrace_src, |
| 425 | | .prev_di_is_stmt = true, |
| 426 | 423 | .rbrace_src = rbrace_src, |
| 427 | 424 | .source = tree.source, |
| 428 | 425 | }; |
| ... | ... | @@ -526,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 526 | 523 | }, |
| 527 | 524 | } |
| 528 | 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 | 529 | fn genBody(self: *Self, body: ir.Body) InnerError!void { |
| ... | ... | @@ -545,15 +542,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 545 | 542 | |
| 546 | 543 | fn dbgSetPrologueEnd(self: *Self) InnerError!void { |
| 547 | 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 | 548 | fn dbgSetEpilogueBegin(self: *Self) InnerError!void { |
| 552 | 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 | 554 | // TODO Look into improving the performance here by adding a token-index-to-line |
| 558 | 555 | // lookup table, and changing ir.Inst from storing byte offset to token. Currently |
| 559 | 556 | // this involves scanning over the source code for newlines |
| ... | ... | @@ -565,11 +562,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 565 | 562 | // TODO Look into using the DWARF special opcodes to compress this data. It lets you emit |
| 566 | 563 | // single-byte opcodes that add different numbers to both the PC and the line number |
| 567 | 564 | // at the same time. |
| 568 | | try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 12); |
| 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 | | } |
| 565 | try self.dbg_line.ensureCapacity(self.dbg_line.items.len + 11); |
| 573 | 566 | self.dbg_line.appendAssumeCapacity(DW.LNS_advance_pc); |
| 574 | 567 | leb128.writeULEB128(self.dbg_line.writer(), delta_pc) catch unreachable; |
| 575 | 568 | if (delta_line != 0) { |
| ... | ... | @@ -1179,7 +1172,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1179 | 1172 | } |
| 1180 | 1173 | |
| 1181 | 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 | 1176 | return MCValue.none; |
| 1184 | 1177 | } |
| 1185 | 1178 | |