summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-03-17 01:52:11 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-03-17 01:52:11 +0000
commitfd69cf9ba4b4a3f29523e2367a569bd84e0fdad8 (patch)
treeb9a4c9ef4ad417fb62b246f05d8f8a4e5c00d8c0 /include
parent6a6b6f50af7fb209c96b359ecd035c6309e5f3f3 (diff)
downloadllvm-fd69cf9ba4b4a3f29523e2367a569bd84e0fdad8.tar.gz
llvm-fd69cf9ba4b4a3f29523e2367a569bd84e0fdad8.tar.bz2
llvm-fd69cf9ba4b4a3f29523e2367a569bd84e0fdad8.tar.xz
DebugInfo: Improve reuse of file table entries in asm debug info
The previous deduping strategy was woefully inadequate - it only considered the most recent file used and avoided emitting a duplicate in that case - never considering the a/b/a scenario. It was also lacking when it came to directory paths as the previous filename would never match the current if the filename had been split into file and directory components. This change builds caching functionality into the line table at the lowest level in an optional form (a file number of 0 indicates that one should be chosen and returned) and will eventually be reused by the normal source level debugging DWARF emission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204027 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/MCContext.h4
-rw-r--r--include/llvm/MC/MCDwarf.h6
-rw-r--r--include/llvm/MC/MCStreamer.h5
3 files changed, 10 insertions, 5 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index b3df225210..b51a5a589f 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -371,7 +371,9 @@ namespace llvm {
bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
- unsigned nextGenDwarfFileNumber() { return ++GenDwarfFileNumber; }
+ void setGenDwarfFileNumber(unsigned FileNumber) {
+ GenDwarfFileNumber = FileNumber;
+ }
const MCSection *getGenDwarfSection() { return GenDwarfSection; }
void setGenDwarfSection(const MCSection *Sec) { GenDwarfSection = Sec; }
MCSymbol *getGenDwarfSectionStartSym() { return GenDwarfSectionStartSym; }
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index abd2f7a2d6..3b60450614 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -16,6 +16,7 @@
#define LLVM_MC_MCDWARF_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Dwarf.h"
@@ -179,8 +180,9 @@ struct MCDwarfLineTableHeader {
MCSymbol *Label;
SmallVector<std::string, 3> MCDwarfDirs;
SmallVector<MCDwarfFile, 3> MCDwarfFiles;
+ StringMap<unsigned> SourceIdMap;
MCDwarfLineTableHeader() : Label(nullptr) {}
- unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber);
+ unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber = 0);
std::pair<MCSymbol *, MCSymbol *> Emit(MCStreamer *MCOS) const;
};
@@ -195,7 +197,7 @@ public:
// This emits the Dwarf file and the line tables for a given Compile Unit.
const MCSymbol *EmitCU(MCStreamer *MCOS) const;
- unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber);
+ unsigned getFile(StringRef Directory, StringRef FileName, unsigned FileNumber = 0);
MCSymbol *getLabel() const {
return Header.Label;
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 18f0e772ef..fc7a3b8648 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -628,8 +628,9 @@ public:
/// EmitDwarfFileDirective - Associate a filename with a specified logical
/// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
/// directive.
- virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
- StringRef Filename, unsigned CUID = 0);
+ virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
+ StringRef Filename,
+ unsigned CUID = 0);
/// EmitDwarfLocDirective - This implements the DWARF2
// '.loc fileno lineno ...' assembler directive.