DebugInfo: Sink accelerator table lists down (GlobalNames/Types) into DwarfCompileUnit
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfCompileUnit.cpp
index bd63279f2fc9779c77944777d45f6e7a4ef0b2c3..d98b30e9b62b4f29126e08f9c766a6be04d6f64c 100644 (file)
@@ -18,7 +18,8 @@ namespace llvm {
 DwarfCompileUnit::DwarfCompileUnit(unsigned UID, DICompileUnit Node,
                                    AsmPrinter *A, DwarfDebug *DW,
                                    DwarfFile *DWU)
-    : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU) {
+    : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
+      Skeleton(nullptr), LabelBegin(nullptr) {
   insertDIE(Node, &getUnitDie());
 }
 
@@ -416,7 +417,7 @@ DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
   DISubprogram InlinedSP = getDISubprogram(DS);
   // Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
   // was inlined from another compile unit.
-  DIE *OriginDIE = DD->getAbstractSPDies()[InlinedSP];
+  DIE *OriginDIE = DU->getAbstractSPDies()[InlinedSP];
   assert(OriginDIE && "Unable to find original DIE for an inlined subprogram.");
 
   auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_inlined_subroutine);
@@ -588,7 +589,7 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
 
 void
 DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
-  DIE *&AbsDef = DD->getAbstractSPDies()[Scope->getScopeNode()];
+  DIE *&AbsDef = DU->getAbstractSPDies()[Scope->getScopeNode()];
   if (AbsDef)
     return;
 
@@ -648,7 +649,7 @@ DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
 
 void DwarfCompileUnit::finishSubprogramDefinition(DISubprogram SP) {
   DIE *D = getDIE(SP);
-  if (DIE *AbsSPDIE = DD->getAbstractSPDies().lookup(SP)) {
+  if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
     if (D)
       // If this subprogram has an abstract definition, reference that
       addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
@@ -671,7 +672,7 @@ void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
   if (Variables.getNumElements() == 0)
     return;
 
-  DIE *SPDIE = DD->getAbstractSPDies().lookup(SP);
+  DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);
   if (!SPDIE)
     SPDIE = getDIE(SP);
   assert(SPDIE);
@@ -685,4 +686,30 @@ void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
   }
 }
 
+void DwarfCompileUnit::emitHeader(const MCSymbol *ASectionSym) const {
+  // Don't bother labeling the .dwo unit, as its offset isn't used.
+  if (!Skeleton)
+    Asm->OutStreamer.EmitLabel(LabelBegin);
+
+  DwarfUnit::emitHeader(ASectionSym);
+}
+
+/// addGlobalName - Add a new global name to the compile unit.
+void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die,
+                                     DIScope Context) {
+  if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly)
+    return;
+  std::string FullName = getParentContextString(Context) + Name.str();
+  GlobalNames[FullName] = &Die;
+}
+
+/// Add a new global type to the unit.
+void DwarfCompileUnit::addGlobalType(DIType Ty, const DIE &Die,
+                                     DIScope Context) {
+  if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly)
+    return;
+  std::string FullName = getParentContextString(Context) + Ty.getName().str();
+  GlobalTypes[FullName] = &Die;
+}
+
 } // end llvm namespace