[PATCH] D108261: [DebugInfo] Fix end_sequence of debug_line in LTO Object

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 13 09:39:22 PST 2021


dblaikie added inline comments.


================
Comment at: llvm/include/llvm/MC/MCDwarf.h:221
+  void addEndEntry(MCSymbol *EndLabel) {
+    if (PrevSec) {
+      auto *LastEntry = &MCLineDivisions[PrevSec].back();
----------------
When does this case come up? I think all of this would only happen when PrevCU was non-null/had been populated with some content first, right?


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2182
+void DwarfDebug::terminateLineTableForPrevCU(const DwarfCompileUnit *NewCU) {
+  if (PrevCU == nullptr || PrevCU == NewCU)
+    return;
----------------
presumably this function shouldn't be called if PrevCU == NewCU, right? (maybe that could be asserted, rather than tested)


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2186
+  const auto &CURanges = PrevCU->getRanges();
+  if (!CURanges.empty()) {
+    auto &LineTable = Asm->OutStreamer->getContext().getMCDwarfLineTable(
----------------
Does is this empty? I /think/ that "PrevCU" is only set when PrevCU has already been populated with some content, right?


================
Comment at: llvm/lib/MC/MCDwarf.cpp:226
   // Generate DWARF line end entry.
   MCOS->emitDwarfLineEndEntry(Section, LastLabel);
 }
----------------
Would be nice if we could eliminate the need for this case - since any time this gets used it risks being because a line table was allowed to "flow off the end" further than it should.

What would it be like if we handled the line table similar to the way ranges are handled? Always terminated at the end of each function, but then extended if the next function happens to start immediately after the last entry ended?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108261/new/

https://reviews.llvm.org/D108261



More information about the llvm-commits mailing list