Sink DwarfDebug::constructInlinedScopeDIE into DwarfCompileUnit

This introduces access to the AbstractSPDies map from DwarfDebug so
DwarfCompileUnit can access it. Eventually this'll sink down to
DwarfFile, but it'll still be generically accessible - not much
encapsulation to provide it. (constructInlinedScopeDIE could stay
further up, in DwarfFile to avoid exposing this - but I don't think
that's particularly better)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219411 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-10-09 16:50:53 +00:00
parent c53401ee91
commit 3fcb9f3ea5
4 changed files with 50 additions and 44 deletions

View File

@ -348,7 +348,7 @@ void DwarfCompileUnit::constructScopeDIE(
// the scope DIE is null.
std::unique_ptr<DIE> ScopeDIE;
if (Scope->getParent() && DS.isSubprogram()) {
ScopeDIE = DD->constructInlinedScopeDIE(*this, Scope);
ScopeDIE = constructInlinedScopeDIE(Scope);
if (!ScopeDIE)
return;
// We create children when the scope DIE is not null.
@ -431,4 +431,34 @@ void DwarfCompileUnit::attachRangesOrLowHighPC(
addScopeRangeList(Die, Ranges);
}
// This scope represents inlined body of a function. Construct DIE to
// represent this concrete inlined copy of the function.
std::unique_ptr<DIE>
DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
assert(Scope->getScopeNode());
DIScope DS(Scope->getScopeNode());
DISubprogram InlinedSP = getDISubprogram(DS);
// Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
// was inlined from another compile unit.
DIE *OriginDIE = DD->getAbstractSPDies()[InlinedSP];
assert(OriginDIE && "Unable to find original DIE for an inlined subprogram.");
auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_inlined_subroutine);
addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
// Add the call site information to the DIE.
DILocation DL(Scope->getInlinedAt());
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
getOrCreateSourceID(DL.getFilename(), DL.getDirectory()));
addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
// Add name to the name table, we do this here because we're guaranteed
// to have concrete versions of our DW_TAG_inlined_subprogram nodes.
DD->addSubprogramNames(InlinedSP, *ScopeDIE);
return ScopeDIE;
}
} // end llvm namespace