diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-29 15:58:35 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-29 15:58:35 +0000 |
commit | e872a6eb91eb915ae643d7bf97304d6f0cff140d (patch) | |
tree | 8ed11c5dcd572014ed0b94d7541b66d7ed9764ee /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 883ae9d9a3c1056ff9910b639f5538b901dc2ca8 (diff) | |
download | bcm5719-llvm-e872a6eb91eb915ae643d7bf97304d6f0cff140d.tar.gz bcm5719-llvm-e872a6eb91eb915ae643d7bf97304d6f0cff140d.zip |
DwarfDebug: Split the initialization of abstract and non-abstract subprogram DIEs.
These were called from distinct places and had significant distinct
behavior. No need to make that a dynamic check inside the function
rather than just having two functions (refactoring some common code into
a helper function to be called from the two separate functions).
llvm-svn: 207539
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 01012071fe1..2b348eaf4d4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -309,7 +309,7 @@ bool DwarfDebug::isSubprogramContext(const MDNode *Context) { // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc // and DW_AT_high_pc attributes. If there are global variables in this // scope then create and insert DIEs for these variables. -DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, +DIE &DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP) { DIE *SPDie = SPCU.getDIE(SP); @@ -359,7 +359,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, // to have concrete versions of our DW_TAG_subprogram nodes. addSubprogramNames(SP, *SPDie); - return SPDie; + return *SPDie; } /// Check whether we should create a DIE for the given Scope, return true @@ -544,40 +544,46 @@ DIE *DwarfDebug::createScopeChildrenDIE( return ObjectPointer; } -DIE *DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU, - LexicalScope *Scope) { - assert(Scope && Scope->getScopeNode()); +void 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; + if (DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children)) + TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer); - DIScope DS(Scope->getScopeNode()); + // Add children + for (auto &I : Children) + ScopeDIE.addChild(std::move(I)); +} +void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope) { + assert(Scope && Scope->getScopeNode()); + assert(Scope->isAbstractScope()); assert(!Scope->getInlinedAt()); - assert(DS.isSubprogram()); - ProcessedSPNodes.insert(DS); + DISubprogram Sub(Scope->getScopeNode()); - SmallVector<std::unique_ptr<DIE>, 8> Children; - DIE *ScopeDIE; + ProcessedSPNodes.insert(Sub); - if (Scope->isAbstractScope()) { - ScopeDIE = TheCU.getDIE(DS); - // Note down abstract DIE. - if (ScopeDIE) - AbstractSPDies.insert(std::make_pair(DS, ScopeDIE)); - else { - assert(Children.empty() && - "We create children only when the scope DIE is not null."); - return nullptr; - } - } else - ScopeDIE = updateSubprogramScopeDIE(TheCU, DISubprogram(DS)); + if (DIE *ScopeDIE = TheCU.getDIE(Sub)) { + AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE)); + createAndAddScopeChildren(TheCU, Scope, *ScopeDIE); + } +} - // We create children when the scope DIE is not null. - if (DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children)) - TheCU.addDIEEntry(*ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer); +DIE &DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU, + LexicalScope *Scope) { + assert(Scope && Scope->getScopeNode()); + assert(!Scope->getInlinedAt()); + assert(!Scope->isAbstractScope()); + assert(DIScope(Scope->getScopeNode()).isSubprogram()); - // Add children - for (auto &I : Children) - ScopeDIE->addChild(std::move(I)); + DISubprogram Sub(Scope->getScopeNode()); + + ProcessedSPNodes.insert(Sub); + + DIE &ScopeDIE = updateSubprogramScopeDIE(TheCU, Sub); + + createAndAddScopeChildren(TheCU, Scope, ScopeDIE); return ScopeDIE; } @@ -1676,10 +1682,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { } } if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0) - constructSubprogramScopeDIE(TheCU, AScope); + constructAbstractSubprogramScopeDIE(TheCU, AScope); } - DIE &CurFnDIE = *constructSubprogramScopeDIE(TheCU, FnScope); + DIE &CurFnDIE = constructSubprogramScopeDIE(TheCU, FnScope); if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn)) TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr); |