diff options
author | Manman Ren <mren@apple.com> | 2013-03-07 01:42:00 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2013-03-07 01:42:00 +0000 |
commit | 3de61b4c0144748e4b9157e2c22fe4ea685981a2 (patch) | |
tree | 76198e1cb0e2d2e257ac269f9cd6175087d2d3bd /include/llvm | |
parent | 55d8f6d49023de5182efbb29d0b3bd0035909d62 (diff) |
Debug Info: store the files and directories for each compile unit.
We now emit a line table for each compile unit. To reduce the prologue size
of each line table, the files and directories used by each compile unit are
stored in std::map<unsigned, std::vector< > > instead of std::vector< >.
The prologue for a lto'ed image can be as big as 93K. Duplicating 93K for each
compile unit causes a huge increase of debug info. With this patch, each
prologue will only emit the files required by the compile unit.
rdar://problem/13342023
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/MC/MCContext.h | 29 | ||||
-rw-r--r-- | include/llvm/MC/MCStreamer.h | 2 |
2 files changed, 21 insertions, 10 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 20d52ebb3e..1251c5fbe2 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -17,6 +17,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" +#include <map> #include <vector> // FIXME: Shouldn't be needed. namespace llvm { @@ -101,8 +102,12 @@ namespace llvm { std::string MainFileName; /// The dwarf file and directory tables from the dwarf .file directive. - std::vector<MCDwarfFile *> MCDwarfFiles; - std::vector<StringRef> MCDwarfDirs; + /// We now emit a line table for each compile unit. To reduce the prologue + /// size of each line table, the files and directories used by each compile + /// unit are separated. + typedef std::map<unsigned, std::vector<MCDwarfFile *> > MCDwarfFilesMap; + MCDwarfFilesMap MCDwarfFilesCUMap; + std::map<unsigned, std::vector<StringRef> > MCDwarfDirsCUMap; /// The current dwarf line information from the last dwarf .loc directive. MCDwarfLoc CurrentDwarfLoc; @@ -282,19 +287,25 @@ namespace llvm { /// GetDwarfFile - creates an entry in the dwarf file and directory tables. unsigned GetDwarfFile(StringRef Directory, StringRef FileName, - unsigned FileNumber); + unsigned FileNumber, unsigned CUID); - bool isValidDwarfFileNumber(unsigned FileNumber); + bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0); bool hasDwarfFiles() const { - return !MCDwarfFiles.empty(); + // Traverse MCDwarfFilesCUMap and check whether each entry is empty. + MCDwarfFilesMap::const_iterator MapB, MapE; + for (MapB = MCDwarfFilesCUMap.begin(), MapE = MCDwarfFilesCUMap.end(); + MapB != MapE; MapB++) + if (!MapB->second.empty()) + return true; + return false; } - const std::vector<MCDwarfFile *> &getMCDwarfFiles() { - return MCDwarfFiles; + const std::vector<MCDwarfFile *> &getMCDwarfFiles(unsigned CUID = 0) { + return MCDwarfFilesCUMap[CUID]; } - const std::vector<StringRef> &getMCDwarfDirs() { - return MCDwarfDirs; + const std::vector<StringRef> &getMCDwarfDirs(unsigned CUID = 0) { + return MCDwarfDirsCUMap[CUID]; } const DenseMap<const MCSection *, MCLineSection *> diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index d247066cd9..a069a2b0ca 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -525,7 +525,7 @@ namespace llvm { /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler /// directive. virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, - StringRef Filename); + StringRef Filename, unsigned CUID = 0); /// EmitDwarfLocDirective - This implements the DWARF2 // '.loc fileno lineno ...' assembler directive. |