[llvm] [MC] Add .loc_label instruction (PR #99710)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 17:37:04 PDT 2024
================
@@ -243,17 +256,36 @@ void MCDwarfLineTable::emitOne(
Discriminator = 0;
LastLine = LineEntry.getLine();
LastLabel = Label;
+ IsAtStartSeq = false;
}
// Generate DWARF line end entry.
// We do not need this for DwarfDebug that explicitly terminates the line
// table using ranges whenever CU or section changes. However, the MC path
// does not track ranges nor terminate the line table. In that case,
// conservatively use the section end symbol to end the line table.
- if (!EndEntryEmitted)
+ if (!EndEntryEmitted && !IsAtStartSeq)
MCOS->emitDwarfLineEndEntry(Section, LastLabel);
}
+void MCDwarfLineTable::endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS,
+ SMLoc DefLoc,
+ StringRef Name) {
+ auto &ctx = MCOS->getContext();
+ auto *LineStreamLabel = ctx.getOrCreateSymbol(Name);
+ auto *LineSym = ctx.createTempSymbol();
+ MCOS->emitLabel(LineSym);
+ const MCDwarfLoc &DwarfLoc = ctx.getCurrentDwarfLoc();
+
+ // Create a 'fake' line entry by having LineStreamLabel be non-null. This
+ // won't actually emit any line information, it will reset the line table
+ // sequence and emit a label at the start of the new line table sequence.
+ MCDwarfLineEntry LineEntry(LineSym, DwarfLoc, LineStreamLabel, DefLoc);
+
+ // Add the line entry to this section's entries.
----------------
MaskRay wrote:
Delete the comment. self-explaining code doesn't need a comment.
https://github.com/llvm/llvm-project/pull/99710
More information about the llvm-commits
mailing list