DebugInfo: Move getOrCreateSourceID from DwarfDebug to DwarfCompileUnit

We still do a few lookups into the line table mapping in MCContext that
could be factored out into a single lookup (rather than looking it up
once for the table label, once to set the compilation unit, once for
each time we need a file ID, etc... ) but assembly output complicates
that somewhat as we still need a virtual dispatch back to the
MCAsmStreamer in that case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-03-17 23:53:25 +00:00
parent 2879a6caa8
commit 1881227389
4 changed files with 22 additions and 31 deletions

View File

@ -540,9 +540,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit *TheCU,
// Add the call site information to the DIE.
DILocation DL(Scope->getInlinedAt());
TheCU->addUInt(ScopeDIE, dwarf::DW_AT_call_file, None,
getOrCreateSourceID(DL.getFilename(), DL.getDirectory(),
TheCU->getUniqueID()));
TheCU->addUInt(
ScopeDIE, dwarf::DW_AT_call_file, None,
TheCU->getOrCreateSourceID(DL.getFilename(), DL.getDirectory()));
TheCU->addUInt(ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
// Add name to the name table, we do this here because we're guaranteed
@ -665,24 +665,6 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit *TheCU,
return ScopeDIE;
}
// Look up the source id with the given directory and source file names.
// If none currently exists, create a new id and insert it in the
// SourceIds map. This can update DirectoryNames and SourceFileNames maps
// as well.
unsigned DwarfDebug::getOrCreateSourceID(StringRef FileName, StringRef DirName,
unsigned CUID) {
// If we print assembly, we can't separate .file entries according to
// compile units. Thus all files will belong to the default compile unit.
// FIXME: add a better feature test than hasRawTextSupport. Even better,
// extend .file to support this.
if (Asm->OutStreamer.hasRawTextSupport())
CUID = 0;
// Print out a .file directive to specify files for .loc directives.
return Asm->OutStreamer.EmitDwarfFileDirective(0, DirName, FileName, CUID);
}
void DwarfDebug::addGnuPubAttributes(DwarfUnit *U, DIE *D) const {
if (!GenerateGnuPubSections)
return;
@ -1759,8 +1741,9 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
} else
llvm_unreachable("Unexpected scope info");
Src = getOrCreateSourceID(
Fn, Dir, Asm->OutStreamer.getContext().getDwarfCompileUnitID());
unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID();
Src = static_cast<DwarfCompileUnit *>(InfoHolder.getUnits()[CUID])
->getOrCreateSourceID(Fn, Dir);
}
Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0,
Discriminator, Fn);