[PATCH] D45589: [DWARF] Defer emitting type units until the compile units are done.

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 13:30:15 PDT 2018


probinson created this revision.
probinson added reviewers: dblaikie, aprantl.
probinson added a project: debug-info.
Herald added subscribers: llvm-commits, JDevlieghere, hiraditya.

This is NFC at the moment but is a prerequisite for emitting type units into the .debug_info[.dwo] section.
Emitting a type unit while in the middle of emitting a compile unit will Just Not Work in DWARF v5.


Repository:
  rL LLVM

https://reviews.llvm.org/D45589

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h


Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -253,6 +253,7 @@
   SmallVector<
       std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
       TypeUnitsUnderConstruction;
+  SmallVector<std::unique_ptr<DwarfTypeUnit>, 1> TypeUnitsToEmit;
 
   /// Whether to use the GNU TLS opcode (instead of the standard opcode).
   bool UseGNUTLSOpcode;
@@ -350,6 +351,10 @@
   /// Emit the debug info section.
   void emitDebugInfo();
 
+  /// Emit the debug type units.  They might go various places, depending on
+  /// the DWARF version and whether we're doing split DWARF.
+  void emitDebugTypes();
+
   /// Emit the abbreviation section.
   void emitAbbreviations();
 
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -841,6 +841,9 @@
     AddrPool.emit(*Asm, Asm->getObjFileLowering().getDwarfAddrSection());
   }
 
+  // Emit the type units, whereever they are supposed to go.
+  emitDebugTypes();
+
   // Emit info into the dwarf accelerator table sections.
   switch (getAccelTableKind()) {
   case AccelTableKind::Apple:
@@ -1445,6 +1448,12 @@
   Holder.emitUnits(/* UseOffsets */ false);
 }
 
+// Emit the type units.
+void DwarfDebug::emitDebugTypes() {
+  for (auto &TU : TypeUnitsToEmit)
+    InfoHolder.emitUnit(TU.get(), useSplitDwarf());
+}
+
 // Emit the abbreviation section.
 void DwarfDebug::emitAbbreviations() {
   DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
@@ -2261,7 +2270,7 @@
     // and all its dependent types.
     for (auto &TU : TypeUnitsToAdd) {
       InfoHolder.computeSizeAndOffsetsForUnit(TU.first.get());
-      InfoHolder.emitUnit(TU.first.get(), useSplitDwarf());
+      TypeUnitsToEmit.emplace_back(std::move(TU.first));
     }
   }
   CU.addDIETypeSignature(RefDie, Signature);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45589.142248.patch
Type: text/x-patch
Size: 2081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180412/b8a91049/attachment.bin>


More information about the llvm-commits mailing list