forked from OSchip/llvm-project
Write only minimal .debug_line information.
Summary: We used to output .debug_line information for every instruction, but because of the way gdb (and probably lldb as of llvm::DWARFDebugLine::LineTable::findAddress) queries the line table it's not necessary to output information for two instructions if they follow each other and map to the same source line. By not repeating this information we generate a bit less .debug_line data. (cherry picked from FBD3056402)
This commit is contained in:
parent
a60914427c
commit
9cdb7bdb55
|
@ -1077,6 +1077,11 @@ void emitFunction(MCStreamer &Streamer, BinaryFunction &Function,
|
|||
if (opts::AlignBlocks && BB->getAlignment() > 1)
|
||||
Streamer.EmitCodeAlignment(BB->getAlignment());
|
||||
Streamer.EmitLabel(BB->getLabel());
|
||||
// Remember last .debug_line entry emitted so that we don't repeat them in
|
||||
// subsequent instructions, as gdb can figure it out by looking at the
|
||||
// previous instruction with available line number info.
|
||||
SMLoc LastLocSeen;
|
||||
|
||||
for (const auto &Instr : *BB) {
|
||||
// Handle pseudo instructions.
|
||||
if (BC.MIA->isEHLabel(Instr)) {
|
||||
|
@ -1090,7 +1095,8 @@ void emitFunction(MCStreamer &Streamer, BinaryFunction &Function,
|
|||
if (!BC.MIA->isCFI(Instr)) {
|
||||
if (opts::UpdateDebugSections) {
|
||||
auto RowReference = DebugLineTableRowRef::fromSMLoc(Instr.getLoc());
|
||||
if (RowReference != DebugLineTableRowRef::NULL_ROW) {
|
||||
if (RowReference != DebugLineTableRowRef::NULL_ROW &&
|
||||
Instr.getLoc().getPointer() != LastLocSeen.getPointer()) {
|
||||
auto CompileUnit =
|
||||
BC.OffsetToDwarfCU[RowReference.DwCompileUnitIndex];
|
||||
assert(CompileUnit &&
|
||||
|
@ -1113,6 +1119,7 @@ void emitFunction(MCStreamer &Streamer, BinaryFunction &Function,
|
|||
OriginalRow.Isa,
|
||||
OriginalRow.Discriminator);
|
||||
BC.Ctx->setDwarfCompileUnitID(CompileUnit->getOffset());
|
||||
LastLocSeen = Instr.getLoc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue