[llvm] r219422 - Sink DwarfDebug::createScopeChildrenDIE down into DwarfCompileUnit.

David Blaikie dblaikie at gmail.com
Thu Oct 9 11:24:29 PDT 2014


Author: dblaikie
Date: Thu Oct  9 13:24:28 2014
New Revision: 219422

URL: http://llvm.org/viewvc/llvm-project?rev=219422&view=rev
Log:
Sink DwarfDebug::createScopeChildrenDIE down into DwarfCompileUnit.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=219422&r1=219421&r2=219422&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Oct  9 13:24:28 2014
@@ -353,7 +353,7 @@ void DwarfCompileUnit::constructScopeDIE
     if (!ScopeDIE)
       return;
     // We create children when the scope DIE is not null.
-    DD->createScopeChildrenDIE(*this, Scope, Children);
+    createScopeChildrenDIE(Scope, Children);
   } else {
     // Early exit when we know the scope DIE is going to be null.
     if (DD->isLexicalScopeDIENull(Scope))
@@ -363,7 +363,7 @@ void DwarfCompileUnit::constructScopeDIE
 
     // We create children here when we know the scope DIE is not going to be
     // null and the children will be added to the scope DIE.
-    DD->createScopeChildrenDIE(*this, Scope, Children, &ChildScopeCount);
+    createScopeChildrenDIE(Scope, Children, &ChildScopeCount);
 
     // There is no need to emit empty lexical block DIE.
     for (const auto &E : DD->findImportedEntitiesForScope(DS))
@@ -550,4 +550,23 @@ std::unique_ptr<DIE> DwarfCompileUnit::c
   return Var;
 }
 
+DIE *DwarfCompileUnit::createScopeChildrenDIE(
+    LexicalScope *Scope, SmallVectorImpl<std::unique_ptr<DIE>> &Children,
+    unsigned *ChildScopeCount) {
+  DIE *ObjectPointer = nullptr;
+
+  for (DbgVariable *DV : DD->getScopeVariables().lookup(Scope))
+    Children.push_back(constructVariableDIE(*DV, *Scope, ObjectPointer));
+
+  unsigned ChildCountWithoutScopes = Children.size();
+
+  for (LexicalScope *LS : Scope->getChildren())
+    constructScopeDIE(LS, Children);
+
+  if (ChildScopeCount)
+    *ChildScopeCount = Children.size() - ChildCountWithoutScopes;
+
+  return ObjectPointer;
+}
+
 } // end llvm namespace

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=219422&r1=219421&r2=219422&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Thu Oct  9 13:24:28 2014
@@ -110,6 +110,11 @@ public:
   std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
                                             const LexicalScope &Scope,
                                             DIE *&ObjectPointer);
+
+  /// A helper function to create children of a Scope DIE.
+  DIE *createScopeChildrenDIE(LexicalScope *Scope,
+                              SmallVectorImpl<std::unique_ptr<DIE>> &Children,
+                              unsigned *ChildScopeCount = nullptr);
 };
 
 } // end llvm namespace

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=219422&r1=219421&r2=219422&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Oct  9 13:24:28 2014
@@ -330,31 +330,11 @@ bool DwarfDebug::isLexicalScopeDIENull(L
   return !getLabelAfterInsn(Ranges.front().second);
 }
 
-DIE *DwarfDebug::createScopeChildrenDIE(
-    DwarfCompileUnit &TheCU, LexicalScope *Scope,
-    SmallVectorImpl<std::unique_ptr<DIE>> &Children,
-    unsigned *ChildScopeCount) {
-  DIE *ObjectPointer = nullptr;
-
-  for (DbgVariable *DV : ScopeVariables.lookup(Scope))
-    Children.push_back(TheCU.constructVariableDIE(*DV, *Scope, ObjectPointer));
-
-  unsigned ChildCountWithoutScopes = Children.size();
-
-  for (LexicalScope *LS : Scope->getChildren())
-    TheCU.constructScopeDIE(LS, Children);
-
-  if (ChildScopeCount)
-    *ChildScopeCount = Children.size() - ChildCountWithoutScopes;
-
-  return ObjectPointer;
-}
-
 DIE *DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU,
                                            LexicalScope *Scope, DIE &ScopeDIE) {
   // We create children when the scope DIE is not null.
   SmallVector<std::unique_ptr<DIE>, 8> Children;
-  DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
+  DIE *ObjectPointer = TheCU.createScopeChildrenDIE(Scope, Children);
 
   // Add children
   for (auto &I : Children)
@@ -1483,6 +1463,8 @@ void DwarfDebug::endFunction(const Machi
     assert(ScopeVariables.empty());
     assert(CurrentFnArguments.empty());
     assert(DbgValues.empty());
+    // FIXME: This wouldn't be true in LTO with a -g (with inlining) CU followed
+    // by a -gmlt CU. Add a test and remove this assertion.
     assert(AbstractVariables.empty());
     LabelsBeforeInsn.clear();
     LabelsAfterInsn.clear();

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=219422&r1=219421&r2=219422&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Oct  9 13:24:28 2014
@@ -675,14 +675,11 @@ public:
 
   // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
 
-  /// A helper function to create children of a Scope DIE.
-  DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
-                              SmallVectorImpl<std::unique_ptr<DIE>> &Children,
-                              unsigned *ChildScopeCount = nullptr);
-
   DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
     return AbstractSPDies;
   }
+
+  ScopeVariablesMap &getScopeVariables() { return ScopeVariables; }
 };
 } // End of namespace llvm
 





More information about the llvm-commits mailing list