From 5465cc67419d590dff8c238b16f9badae6a6e5be Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 9 Oct 2014 18:24:28 +0000 Subject: [PATCH] Sink DwarfDebug::createScopeChildrenDIE down into DwarfCompileUnit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219422 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 23 ++++++++++++++++++-- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 5 +++++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 24 +++------------------ lib/CodeGen/AsmPrinter/DwarfDebug.h | 7 ++---- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 26cca502216..52da4e77411 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -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 DwarfCompileUnit::constructVariableDIE( return Var; } +DIE *DwarfCompileUnit::createScopeChildrenDIE( + LexicalScope *Scope, SmallVectorImpl> &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 diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 9ad503cb882..b9a8a5ee1c0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -110,6 +110,11 @@ public: std::unique_ptr constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, DIE *&ObjectPointer); + + /// A helper function to create children of a Scope DIE. + DIE *createScopeChildrenDIE(LexicalScope *Scope, + SmallVectorImpl> &Children, + unsigned *ChildScopeCount = nullptr); }; } // end llvm namespace diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 75206d2d85d..2b71f845383 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -330,31 +330,11 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) { return !getLabelAfterInsn(Ranges.front().second); } -DIE *DwarfDebug::createScopeChildrenDIE( - DwarfCompileUnit &TheCU, LexicalScope *Scope, - SmallVectorImpl> &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, 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 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(); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index d08334d5ec0..099b136ad23 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -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> &Children, - unsigned *ChildScopeCount = nullptr); - DenseMap &getAbstractSPDies() { return AbstractSPDies; } + + ScopeVariablesMap &getScopeVariables() { return ScopeVariables; } }; } // End of namespace llvm