mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-03 08:55:51 +00:00
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207539 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ec96ef30c9
commit
4b26377660
@ -309,7 +309,7 @@ bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
|
|||||||
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
|
// 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
|
// and DW_AT_high_pc attributes. If there are global variables in this
|
||||||
// scope then create and insert DIEs for these variables.
|
// scope then create and insert DIEs for these variables.
|
||||||
DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU,
|
DIE &DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit &SPCU,
|
||||||
DISubprogram SP) {
|
DISubprogram SP) {
|
||||||
DIE *SPDie = SPCU.getDIE(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.
|
// to have concrete versions of our DW_TAG_subprogram nodes.
|
||||||
addSubprogramNames(SP, *SPDie);
|
addSubprogramNames(SP, *SPDie);
|
||||||
|
|
||||||
return SPDie;
|
return *SPDie;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether we should create a DIE for the given Scope, return true
|
/// Check whether we should create a DIE for the given Scope, return true
|
||||||
@ -544,40 +544,46 @@ DIE *DwarfDebug::createScopeChildrenDIE(
|
|||||||
return ObjectPointer;
|
return ObjectPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIE *DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
|
void DwarfDebug::createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope, DIE &ScopeDIE) {
|
||||||
LexicalScope *Scope) {
|
|
||||||
assert(Scope && Scope->getScopeNode());
|
|
||||||
|
|
||||||
DIScope DS(Scope->getScopeNode());
|
|
||||||
|
|
||||||
assert(!Scope->getInlinedAt());
|
|
||||||
assert(DS.isSubprogram());
|
|
||||||
|
|
||||||
ProcessedSPNodes.insert(DS);
|
|
||||||
|
|
||||||
SmallVector<std::unique_ptr<DIE>, 8> Children;
|
|
||||||
DIE *ScopeDIE;
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
// We create children when the scope DIE is not null.
|
// We create children when the scope DIE is not null.
|
||||||
|
SmallVector<std::unique_ptr<DIE>, 8> Children;
|
||||||
if (DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children))
|
if (DIE *ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children))
|
||||||
TheCU.addDIEEntry(*ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
|
TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
|
||||||
|
|
||||||
// Add children
|
// Add children
|
||||||
for (auto &I : Children)
|
for (auto &I : Children)
|
||||||
ScopeDIE->addChild(std::move(I));
|
ScopeDIE.addChild(std::move(I));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope) {
|
||||||
|
assert(Scope && Scope->getScopeNode());
|
||||||
|
assert(Scope->isAbstractScope());
|
||||||
|
assert(!Scope->getInlinedAt());
|
||||||
|
|
||||||
|
DISubprogram Sub(Scope->getScopeNode());
|
||||||
|
|
||||||
|
ProcessedSPNodes.insert(Sub);
|
||||||
|
|
||||||
|
if (DIE *ScopeDIE = TheCU.getDIE(Sub)) {
|
||||||
|
AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE));
|
||||||
|
createAndAddScopeChildren(TheCU, Scope, *ScopeDIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DIE &DwarfDebug::constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
|
||||||
|
LexicalScope *Scope) {
|
||||||
|
assert(Scope && Scope->getScopeNode());
|
||||||
|
assert(!Scope->getInlinedAt());
|
||||||
|
assert(!Scope->isAbstractScope());
|
||||||
|
assert(DIScope(Scope->getScopeNode()).isSubprogram());
|
||||||
|
|
||||||
|
DISubprogram Sub(Scope->getScopeNode());
|
||||||
|
|
||||||
|
ProcessedSPNodes.insert(Sub);
|
||||||
|
|
||||||
|
DIE &ScopeDIE = updateSubprogramScopeDIE(TheCU, Sub);
|
||||||
|
|
||||||
|
createAndAddScopeChildren(TheCU, Scope, ScopeDIE);
|
||||||
|
|
||||||
return ScopeDIE;
|
return ScopeDIE;
|
||||||
}
|
}
|
||||||
@ -1676,10 +1682,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0)
|
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))
|
if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn))
|
||||||
TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
|
TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
|
/// 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 in this scope then create and insert DIEs for these
|
||||||
/// variables.
|
/// variables.
|
||||||
DIE *updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
|
DIE &updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
|
||||||
|
|
||||||
/// \brief A helper function to check whether the DIE for a given Scope is
|
/// \brief A helper function to check whether the DIE for a given Scope is
|
||||||
/// going to be null.
|
/// going to be null.
|
||||||
@ -370,8 +370,12 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
/// \brief Construct a DIE for this scope.
|
/// \brief Construct a DIE for this scope.
|
||||||
std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU,
|
std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU,
|
||||||
LexicalScope *Scope);
|
LexicalScope *Scope);
|
||||||
/// \brief Construct a DIE for this scope.
|
void createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
|
||||||
DIE *constructSubprogramScopeDIE(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 subprogram scope.
|
||||||
|
DIE &constructSubprogramScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
|
||||||
/// A helper function to create children of a Scope DIE.
|
/// A helper function to create children of a Scope DIE.
|
||||||
DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
|
DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
|
||||||
SmallVectorImpl<std::unique_ptr<DIE>> &Children);
|
SmallVectorImpl<std::unique_ptr<DIE>> &Children);
|
||||||
|
Loading…
Reference in New Issue
Block a user