Sink DwarfDebug::constructSubprogramScopeDIE down into DwarfCompileUnit
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 9 Oct 2014 20:21:36 +0000 (20:21 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 9 Oct 2014 20:21:36 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219436 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h

index 52da4e77411cead342eacd2583f1f06224622ba4..13bd12ee2049d91c8bf80fa6b7a3123d3cffa177 100644 (file)
@@ -569,4 +569,44 @@ DIE *DwarfCompileUnit::createScopeChildrenDIE(
   return ObjectPointer;
 }
 
   return ObjectPointer;
 }
 
+void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) {
+  assert(Scope && Scope->getScopeNode());
+  assert(!Scope->getInlinedAt());
+  assert(!Scope->isAbstractScope());
+  DISubprogram Sub(Scope->getScopeNode());
+
+  assert(Sub.isSubprogram());
+
+  DD->getProcessedSPNodes().insert(Sub);
+
+  DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
+
+  // Collect arguments for current function.
+  DIE *ObjectPointer = nullptr;
+  for (DbgVariable *ArgDV : DD->getCurrentFnArguments())
+    if (ArgDV)
+      ScopeDIE.addChild(constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
+
+  // If this is a variadic function, add an unspecified parameter.
+  DITypeArray FnArgs = Sub.getType().getTypeArray();
+  // If we have a single element of null, it is a function that returns void.
+  // If we have more than one elements and the last one is null, it is a
+  // variadic function.
+  if (FnArgs.getNumElements() > 1 &&
+      !FnArgs.getElement(FnArgs.getNumElements() - 1))
+    ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
+
+  // Collect lexical scope children first.
+  // ObjectPointer might be a local (non-argument) local variable if it's a
+  // block's synthetic this pointer.
+  if (DIE *BlockObjPtr =
+          DD->createAndAddScopeChildren(*this, Scope, ScopeDIE)) {
+    assert(!ObjectPointer && "multiple object pointers can't be described");
+    ObjectPointer = BlockObjPtr;
+  }
+
+  if (ObjectPointer)
+    addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
+}
+
 } // end llvm namespace
 } // end llvm namespace
index b9a8a5ee1c02d3b889d7defe50090dc613b910c4..fb6a867cc7d918bbdeb33a11a44eadde4447ba35 100644 (file)
@@ -115,6 +115,9 @@ public:
   DIE *createScopeChildrenDIE(LexicalScope *Scope,
                               SmallVectorImpl<std::unique_ptr<DIE>> &Children,
                               unsigned *ChildScopeCount = nullptr);
   DIE *createScopeChildrenDIE(LexicalScope *Scope,
                               SmallVectorImpl<std::unique_ptr<DIE>> &Children,
                               unsigned *ChildScopeCount = nullptr);
+
+  /// \brief Construct a DIE for this subprogram scope.
+  void constructSubprogramScopeDIE(LexicalScope *Scope);
 };
 
 } // end llvm namespace
 };
 
 } // end llvm namespace
index 2b71f845383faaa5a16380ea701c6cde6c93b518..49afdf275e3cb1f9a7aaf03f4880d80bb20be5f8 100644 (file)
@@ -384,48 +384,6 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
     SPCU.addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
 }
 
     SPCU.addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
 }
 
-void DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
-                                             LexicalScope *Scope) {
-  assert(Scope && Scope->getScopeNode());
-  assert(!Scope->getInlinedAt());
-  assert(!Scope->isAbstractScope());
-  DISubprogram Sub(Scope->getScopeNode());
-
-  assert(Sub.isSubprogram());
-
-  ProcessedSPNodes.insert(Sub);
-
-  DIE &ScopeDIE = TheCU.updateSubprogramScopeDIE(Sub);
-
-  // Collect arguments for current function.
-  assert(LScopes.isCurrentFunctionScope(Scope));
-  DIE *ObjectPointer = nullptr;
-  for (DbgVariable *ArgDV : CurrentFnArguments)
-    if (ArgDV)
-      ScopeDIE.addChild(
-          TheCU.constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
-
-  // If this is a variadic function, add an unspecified parameter.
-  DITypeArray FnArgs = Sub.getType().getTypeArray();
-  // If we have a single element of null, it is a function that returns void.
-  // If we have more than one elements and the last one is null, it is a
-  // variadic function.
-  if (FnArgs.getNumElements() > 1 &&
-      !FnArgs.getElement(FnArgs.getNumElements() - 1))
-    ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
-
-  // Collect lexical scope children first.
-  // ObjectPointer might be a local (non-argument) local variable if it's a
-  // block's synthetic this pointer.
-  if (DIE *BlockObjPtr = createAndAddScopeChildren(TheCU, Scope, ScopeDIE)) {
-    assert(!ObjectPointer && "multiple object pointers can't be described");
-    ObjectPointer = BlockObjPtr;
-  }
-
-  if (ObjectPointer)
-    TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
-}
-
 void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE &D) const {
   if (!GenerateGnuPubSections)
     return;
 void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE &D) const {
   if (!GenerateGnuPubSections)
     return;
@@ -1489,7 +1447,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
     constructAbstractSubprogramScopeDIE(TheCU, AScope);
   }
 
     constructAbstractSubprogramScopeDIE(TheCU, AScope);
   }
 
-  constructSubprogramScopeDIE(TheCU, FnScope);
+  TheCU.constructSubprogramScopeDIE(FnScope);
 
   // Clear debug info
   // Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the
 
   // Clear debug info
   // Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the
index 099b136ad23ad807f3f992024acb419dfdc5bf6b..7d72602792f749538c53ebe776c80ae6a0952c57 100644 (file)
@@ -349,15 +349,9 @@ class DwarfDebug : public AsmPrinterHandler {
   void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
                                                const MDNode *Scope);
 
   void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
                                                const MDNode *Scope);
 
-  DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
-                                 DIE &ScopeDIE);
   /// \brief Construct a DIE for this abstract scope.
   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
                                            LexicalScope *Scope);
   /// \brief Construct a DIE for this abstract scope.
   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
                                            LexicalScope *Scope);
-  /// \brief Construct a DIE for this subprogram scope.
-  void constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
-                                   LexicalScope *Scope);
-
   /// \brief Emit initial Dwarf sections with a label at the start of each one.
   void emitSectionLabels();
 
   /// \brief Emit initial Dwarf sections with a label at the start of each one.
   void emitSectionLabels();
 
@@ -680,6 +674,17 @@ public:
   }
 
   ScopeVariablesMap &getScopeVariables() { return ScopeVariables; }
   }
 
   ScopeVariablesMap &getScopeVariables() { return ScopeVariables; }
+
+  SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
+    return ProcessedSPNodes;
+  }
+
+  SmallVector<DbgVariable *, 8> &getCurrentFnArguments() {
+    return CurrentFnArguments;
+  }
+
+  DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
+                                 DIE &ScopeDIE);
 };
 } // End of namespace llvm
 
 };
 } // End of namespace llvm