Sink DwarfDebug::createScopeChildrenDIE down into DwarfCompileUnit.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.cpp
index a45e5ba06849409544df397bcd1b9cdf72dd8616..2b71f845383faaa5a16380ea701c6cde6c93b518 100644 (file)
@@ -330,41 +330,11 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
   return !getLabelAfterInsn(Ranges.front().second);
 }
 
-static std::unique_ptr<DIE> constructVariableDIE(DwarfCompileUnit &TheCU,
-                                                 DbgVariable &DV,
-                                                 const LexicalScope &Scope,
-                                                 DIE *&ObjectPointer) {
-  auto Var = TheCU.constructVariableDIE(DV, Scope.isAbstractScope());
-  if (DV.isObjectPointer())
-    ObjectPointer = Var.get();
-  return Var;
-}
-
-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(constructVariableDIE(TheCU, *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)
@@ -433,7 +403,7 @@ void DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
   for (DbgVariable *ArgDV : CurrentFnArguments)
     if (ArgDV)
       ScopeDIE.addChild(
-          constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
+          TheCU.constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
 
   // If this is a variadic function, add an unspecified parameter.
   DITypeArray FnArgs = Sub.getType().getTypeArray();
@@ -1493,6 +1463,8 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
     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();