DebugInfo: Separate out the addition of subprogram attribute additions so that they can be added later depending on whether or not the function is inlined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-05-27 18:37:38 +00:00
parent 3efc250128
commit 75325b9f65
2 changed files with 17 additions and 9 deletions

View File

@ -1374,24 +1374,32 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Construct the context before querying for the existence of the DIE in case // Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE (as is the case for member function // such construction creates the DIE (as is the case for member function
// declarations). // declarations).
DIScope Context = resolve(SP.getContext()); DIE *ContextDIE = getOrCreateContextDIE(resolve(SP.getContext()));
DIE *ContextDIE = getOrCreateContextDIE(Context);
if (DIE *SPDie = getDIE(SP)) if (DIE *SPDie = getDIE(SP))
return SPDie; return SPDie;
DIE *DeclDie = nullptr;
StringRef DeclLinkageName;
if (DISubprogram SPDecl = SP.getFunctionDeclaration()) { if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
// Add subprogram definitions to the CU die directly. // Add subprogram definitions to the CU die directly.
ContextDIE = &getUnitDie(); ContextDIE = &getUnitDie();
DeclDie = getOrCreateSubprogramDIE(SPDecl); // Build the decl now to ensure it preceeds the definition.
DeclLinkageName = SPDecl.getLinkageName(); getOrCreateSubprogramDIE(SPDecl);
} }
// DW_TAG_inlined_subroutine may refer to this DIE. // DW_TAG_inlined_subroutine may refer to this DIE.
DIE &SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP); DIE &SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP);
applySubprogramAttributes(SP, SPDie);
return &SPDie;
}
void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie) {
DIE *DeclDie = nullptr;
StringRef DeclLinkageName;
if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
DeclDie = getOrCreateSubprogramDIE(SPDecl);
DeclLinkageName = SPDecl.getLinkageName();
}
// Add function template parameters. // Add function template parameters.
addTemplateParams(SPDie, SP.getTemplateParams()); addTemplateParams(SPDie, SP.getTemplateParams());
@ -1409,7 +1417,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Refer to the function declaration where all the other attributes will be // Refer to the function declaration where all the other attributes will be
// found. // found.
addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie); addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
return &SPDie; return;
} }
// Constructors and operators for anonymous aggregates do not have names. // Constructors and operators for anonymous aggregates do not have names.
@ -1486,8 +1494,6 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
if (SP.isExplicit()) if (SP.isExplicit())
addFlag(SPDie, dwarf::DW_AT_explicit); addFlag(SPDie, dwarf::DW_AT_explicit);
return &SPDie;
} }
// Return const expression if value is a GEP to access merged global // Return const expression if value is a GEP to access merged global

View File

@ -401,6 +401,8 @@ public:
/// getOrCreateSubprogramDIE - Create new DIE using SP. /// getOrCreateSubprogramDIE - Create new DIE using SP.
DIE *getOrCreateSubprogramDIE(DISubprogram SP); DIE *getOrCreateSubprogramDIE(DISubprogram SP);
void applySubprogramAttributes(DISubprogram SP, DIE &SPDie);
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
/// given DIType. /// given DIType.
DIE *getOrCreateTypeDIE(const MDNode *N); DIE *getOrCreateTypeDIE(const MDNode *N);