diff options
author | alx32 <103613512+alx32@users.noreply.github.com> | 2024-09-20 06:32:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 06:32:34 -0700 |
commit | 28646d0cc12a01b0de2e4eb982cb91590bc2f84a (patch) | |
tree | eb5c49a1ac208bf04c719e67544a25965d185f3f /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 42b696d7b9942fdf07d65267da40ab178464adaa (diff) | |
download | llvm-28646d0cc12a01b0de2e4eb982cb91590bc2f84a.zip llvm-28646d0cc12a01b0de2e4eb982cb91590bc2f84a.tar.gz llvm-28646d0cc12a01b0de2e4eb982cb91590bc2f84a.tar.bz2 |
[MC] Add .loc_label instruction (#99710)
As discussed in [the
RFC](https://discourse.llvm.org/t/rfc-extending-llvm-mc-loc-directive-with-labeling-support/79608)
we need a way to create labels in the assembler-generated line section
in order to support the future addition of the
[DW_AT_LLVM_stmt_sequence](https://discourse.llvm.org/t/rfc-new-dwarf-attribute-for-symbolication-of-merged-functions/79434)
attribute.
We have a similar precedent for such behavior with the
[.cfi_label](https://github.com/llvm/llvm-project/pull/97922)
instruction - so we add the `.loc_label THE_LABEL_NAME` instruction
which:
- Terminates the current line sequence in the line section
- Creates a new label with the specified label name in the `.debug_line`
section
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 9dc3974..b2b2143 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -467,12 +467,16 @@ void MCObjectStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta, } void MCObjectStreamer::emitDwarfLineEndEntry(MCSection *Section, - MCSymbol *LastLabel) { - // Emit a DW_LNE_end_sequence for the end of the section. - // Use the section end label to compute the address delta and use INT64_MAX - // as the line delta which is the signal that this is actually a + MCSymbol *LastLabel, + MCSymbol *EndLabel) { + // Emit a DW_LNE_end_sequence into the line table. When EndLabel is null, it + // means we should emit the entry for the end of the section and therefore we + // use the section end label for the reference label. After having the + // appropriate reference label, we emit the address delta and use INT64_MAX as + // the line delta which is the signal that this is actually a // DW_LNE_end_sequence. - MCSymbol *SectionEnd = endSection(Section); + if (!EndLabel) + EndLabel = endSection(Section); // Switch back the dwarf line section, in case endSection had to switch the // section. @@ -480,7 +484,7 @@ void MCObjectStreamer::emitDwarfLineEndEntry(MCSection *Section, switchSection(Ctx.getObjectFileInfo()->getDwarfLineSection()); const MCAsmInfo *AsmInfo = Ctx.getAsmInfo(); - emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd, + emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, EndLabel, AsmInfo->getCodePointerSize()); } |