summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCContext.cpp29
-rw-r--r--llvm/lib/MC/MCDwarf.cpp9
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp3
3 files changed, 20 insertions, 21 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index b601ab24434..606da252689 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -540,19 +540,26 @@ void MCContext::addDebugPrefixMapEntry(const std::string &From,
DebugPrefixMap.insert(std::make_pair(From, To));
}
-void MCContext::RemapDebugPath(std::string *Path) {
- for (const auto &Entry : DebugPrefixMap)
- if (StringRef(*Path).startswith(Entry.first)) {
- std::string RemappedPath =
- (Twine(Entry.second) + Path->substr(Entry.first.size())).str();
- Path->swap(RemappedPath);
- }
-}
-
-void MCContext::RemapCompilationDir() {
+void MCContext::RemapDebugPaths() {
+ const auto &DebugPrefixMap = this->DebugPrefixMap;
+ const auto RemapDebugPath = [&DebugPrefixMap](std::string &Path) {
+ for (const auto &Entry : DebugPrefixMap)
+ if (StringRef(Path).startswith(Entry.first)) {
+ std::string RemappedPath =
+ (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
+ Path.swap(RemappedPath);
+ }
+ };
+
+ // Remap compilation directory.
std::string CompDir = CompilationDir.str();
- RemapDebugPath(&CompDir);
+ RemapDebugPath(CompDir);
CompilationDir = CompDir;
+
+ // Remap MCDwarfDirs in all compilation units.
+ for (auto &CUIDTablePair : MCDwarfLineTablesCUMap)
+ for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs())
+ RemapDebugPath(Dir);
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 1d33d9947be..6131fcd658b 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -251,9 +251,7 @@ void MCDwarfLineTable::Emit(MCObjectStreamer *MCOS,
// Handle the rest of the Compile Units.
for (const auto &CUIDTablePair : LineTables) {
- auto &LineTable = context.getMCDwarfLineTable(CUIDTablePair.first);
- LineTable.RemapDwarfDirs(MCOS->getContext());
- LineTable.EmitCU(MCOS, Params, LineStr);
+ CUIDTablePair.second.EmitCU(MCOS, Params, LineStr);
}
if (LineStr)
@@ -634,11 +632,6 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
return FileNumber;
}
-void MCDwarfLineTable::RemapDwarfDirs(MCContext &Context) {
- for (auto &Dir : Header.MCDwarfDirs)
- Context.RemapDebugPath(&Dir);
-}
-
/// Utility function to emit the encoding to a streamer.
void MCDwarfLineAddr::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
int64_t LineDelta, uint64_t AddrDelta) {
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 9fab8d835f8..9d536883b98 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -661,8 +661,7 @@ void MCObjectStreamer::EmitFileDirective(StringRef Filename) {
}
void MCObjectStreamer::FinishImpl() {
- // Remap the compilation directory before emitting.
- getContext().RemapCompilationDir();
+ getContext().RemapDebugPaths();
// If we are generating dwarf for assembly source files dump out the sections.
if (getContext().getGenDwarfForAssembly())
OpenPOWER on IntegriCloud