summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-03-17 23:53:25 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-03-17 23:53:25 +0000
commit1881227389bfb5a39bd47ccc84504d8d81031bf5 (patch)
tree0aba04c12c5b25fda9549cd86433723385a367fc /lib
parent2879a6caa8d1146946e5c5287d3ff905a2da66bd (diff)
downloadllvm-1881227389bfb5a39bd47ccc84504d8d81031bf5.tar.gz
llvm-1881227389bfb5a39bd47ccc84504d8d81031bf5.tar.bz2
llvm-1881227389bfb5a39bd47ccc84504d8d81031bf5.tar.xz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp29
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h6
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.cpp14
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.h4
4 files changed, 22 insertions, 31 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5b05ee1f73..8c499f8493 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -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);
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 3ab537037d..7f4ed6e290 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -737,12 +737,6 @@ public:
SymSize[Sym] = Size;
}
- /// \brief 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.
- unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
- unsigned CUID);
-
/// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die);
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 0b72e969d4..9b7e38f9bd 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -296,6 +296,17 @@ void DwarfCompileUnit::addLabelAddress(DIE *Die, dwarf::Attribute Attribute,
}
}
+unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName, StringRef DirName) {
+ // 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.
+ return Asm->OutStreamer.EmitDwarfFileDirective(
+ 0, DirName, FileName,
+ Asm->OutStreamer.hasRawTextSupport() ? 0 : getUniqueID());
+}
+
/// addOpAddress - Add a dwarf op address data and value using the
/// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
///
@@ -383,8 +394,7 @@ void DwarfUnit::addSourceLine(DIE *Die, unsigned Line, StringRef File,
if (Line == 0)
return;
- unsigned FileID =
- DD->getOrCreateSourceID(File, Directory, getCU().getUniqueID());
+ unsigned FileID = getCU().getOrCreateSourceID(File, Directory);
assert(FileID && "Invalid file id");
addUInt(Die, dwarf::DW_AT_decl_file, None, FileID);
addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h
index d820873766..705c95bf28 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -602,6 +602,10 @@ public:
void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
DwarfCompileUnit &getCU() override { return *this; }
+
+ /// 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 line table.
+ unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName);
};
class DwarfTypeUnit : public DwarfUnit {