diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-05-20 21:26:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-20 21:26:56 +0100 |
commit | 26d9cb17a6e655993c991b66b21d5c378256d79b (patch) | |
tree | a8daa54e7b2aaebe323ca0d9ff287291483dafa2 /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 705e27c23474f3177670a791b5b54eefedee0cd8 (diff) | |
download | llvm-26d9cb17a6e655993c991b66b21d5c378256d79b.zip llvm-26d9cb17a6e655993c991b66b21d5c378256d79b.tar.gz llvm-26d9cb17a6e655993c991b66b21d5c378256d79b.tar.bz2 |
[MC][DebugInfo] Emit linetable entries with known offsets immediately (#134677)
DWARF linetable entries are usually emitted as a sequence of
MCDwarfLineAddrFragment fragments containing the line-number difference
and an MCExpr describing the instruction-range the linetable entry
covers. These then get relaxed during assembly emission.
However, a large number of these instruction-range expressions are
ranges within a fixed MCDataFragment, i.e. a range over fixed-size
instructions that are not subject to relaxation at a later stage. Thus,
we can compute the address-delta immediately, and not spend time and
memory describing that computation so it can be deferred.
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index e9295f0..7036c40 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -464,6 +464,18 @@ void MCObjectStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta, Label, PointerSize); return; } + + // If the two labels are within the same fragment, then the address-offset is + // already a fixed constant and is not relaxable. Emit the advance-line-addr + // data immediately to save time and memory. + if (auto OptAddrDelta = absoluteSymbolDiff(Label, LastLabel)) { + SmallString<16> Tmp; + MCDwarfLineAddr::encode(getContext(), Assembler->getDWARFLinetableParams(), + LineDelta, *OptAddrDelta, Tmp); + emitBytes(Tmp); + return; + } + const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel, SMLoc()); insert(getContext().allocFragment<MCDwarfLineAddrFragment>(LineDelta, *AddrDelta)); |