[llvm] ed8f29d - [Debug-Info][NFC] use emitDwarfUnitLength for debug line section

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 19:34:30 PST 2021


Author: Chen Zheng
Date: 2021-02-27T22:33:49-05:00
New Revision: ed8f29d91ecd5be9854073dc1e0e78660d3dff78

URL: https://github.com/llvm/llvm-project/commit/ed8f29d91ecd5be9854073dc1e0e78660d3dff78
DIFF: https://github.com/llvm/llvm-project/commit/ed8f29d91ecd5be9854073dc1e0e78660d3dff78.diff

LOG: [Debug-Info][NFC] use emitDwarfUnitLength for debug line section

Use emitDwarfUnitLength for debug line, so we can benefit from
overriding of emitDwarfUnitLength inside different streamers.

Reviewed By: ikudrin, dblaikie

Differential Revision: https://reviews.llvm.org/D95998

Added: 
    

Modified: 
    llvm/lib/MC/MCDwarf.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index f86d4266a1eb..df04f113741d 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -474,48 +474,30 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
   // Set the value of the symbol, as we are at the start of the line table.
   MCOS->emitLabel(LineStartSym);
 
-  // Create a symbol for the end of the section (to be set when we get there).
-  MCSymbol *LineEndSym = context.createTempSymbol();
-
-  unsigned UnitLengthBytes =
-      dwarf::getUnitLengthFieldByteSize(context.getDwarfFormat());
   unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(context.getDwarfFormat());
 
-  if (context.getDwarfFormat() == dwarf::DWARF64)
-    // Emit DWARF64 mark.
-    MCOS->emitInt32(dwarf::DW_LENGTH_DWARF64);
-
-  // The length field does not include itself and, in case of the 64-bit DWARF
-  // format, the DWARF64 mark.
-  emitAbsValue(*MCOS,
-               makeEndMinusStartExpr(context, *LineStartSym, *LineEndSym,
-                                     UnitLengthBytes),
-               OffsetSize);
+  MCSymbol *LineEndSym = MCOS->emitDwarfUnitLength("debug_line", "unit length");
 
   // Next 2 bytes is the Version.
   unsigned LineTableVersion = context.getDwarfVersion();
   MCOS->emitInt16(LineTableVersion);
 
-  // Keep track of the bytes between the very start and where the header length
-  // comes out.
-  unsigned PreHeaderLengthBytes = UnitLengthBytes + 2;
-
   // In v5, we get address info next.
   if (LineTableVersion >= 5) {
     MCOS->emitInt8(context.getAsmInfo()->getCodePointerSize());
     MCOS->emitInt8(0); // Segment selector; same as EmitGenDwarfAranges.
-    PreHeaderLengthBytes += 2;
   }
 
+  MCSymbol *ProStartSym = context.createTempSymbol();
+
   // Create a symbol for the end of the prologue (to be set when we get there).
   MCSymbol *ProEndSym = context.createTempSymbol(); // Lprologue_end
 
   // Length of the prologue, is the next 4 bytes (8 bytes for DWARF64). This is
   // actually the length from after the length word, to the end of the prologue.
-  emitAbsValue(*MCOS,
-               makeEndMinusStartExpr(context, *LineStartSym, *ProEndSym,
-                                     (PreHeaderLengthBytes + OffsetSize)),
-               OffsetSize);
+  MCOS->emitAbsoluteSymbolDiff(ProEndSym, ProStartSym, OffsetSize);
+
+  MCOS->emitLabel(ProStartSym);
 
   // Parameters of the state machine, are next.
   MCOS->emitInt8(context.getAsmInfo()->getMinInstAlignment());


        


More information about the llvm-commits mailing list