summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-24 16:58:59 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-24 16:58:59 +0000
commit882a2b5a7d8a91d1dafb66a25b6ac16377f1bf12 (patch)
tree3bf221d23d6e3991834416a1b6fc495b779f69ef /llvm/lib/CodeGen
parent9d50e82fb2324621dcdd43f68e08ae2d775378c3 (diff)
downloadbcm5719-llvm-882a2b5a7d8a91d1dafb66a25b6ac16377f1bf12.tar.gz
bcm5719-llvm-882a2b5a7d8a91d1dafb66a25b6ac16377f1bf12.zip
AsmPrinter: Avoid creating symbols in DwarfStringPool
Stop creating symbols we don't need in `DwarfStringPool`. The consumers only call `DwarfStringPoolEntryRef::getSymbol()` when DWARF is relocatable, so this just stops creating the unused symbols when it's not. This drops memory usage from 851 MB to 845 MB, around 0.7%. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238122
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp14
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h4
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
index 29cae87a14d..2066f745e31 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
@@ -9,10 +9,16 @@
#include "DwarfStringPool.h"
#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
using namespace llvm;
+DwarfStringPool::DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm,
+ StringRef Prefix)
+ : Pool(A), Prefix(Prefix),
+ ShouldCreateSymbols(Asm.MAI->doesDwarfUseRelocationsAcrossSections()) {}
+
DwarfStringPool::EntryRef DwarfStringPool::getEntry(AsmPrinter &Asm,
StringRef Str) {
auto I = Pool.insert(std::make_pair(Str, EntryTy()));
@@ -20,7 +26,7 @@ DwarfStringPool::EntryRef DwarfStringPool::getEntry(AsmPrinter &Asm,
auto &Entry = I.first->second;
Entry.Index = Pool.size() - 1;
Entry.Offset = NumBytes;
- Entry.Symbol = Asm.createTempSymbol(Prefix);
+ Entry.Symbol = ShouldCreateSymbols ? Asm.createTempSymbol(Prefix) : nullptr;
NumBytes += Str.size() + 1;
assert(NumBytes > Entry.Offset && "Unexpected overflow");
@@ -44,8 +50,12 @@ void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
Entries[E.getValue().Index] = &E;
for (const auto &Entry : Entries) {
+ assert(ShouldCreateSymbols == static_cast<bool>(Entry->getValue().Symbol) &&
+ "Mismatch between setting and entry");
+
// Emit a label for reference from debug information entries.
- Asm.OutStreamer->EmitLabel(Entry->getValue().Symbol);
+ if (ShouldCreateSymbols)
+ Asm.OutStreamer->EmitLabel(Entry->getValue().Symbol);
// Emit the string itself with a terminating null byte.
Asm.OutStreamer->AddComment("string offset=" +
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h
index b042350fb59..93a168485a5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h
@@ -30,12 +30,12 @@ class DwarfStringPool {
StringMap<EntryTy, BumpPtrAllocator &> Pool;
StringRef Prefix;
unsigned NumBytes = 0;
+ bool ShouldCreateSymbols;
public:
typedef DwarfStringPoolEntryRef EntryRef;
- DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
- : Pool(A), Prefix(Prefix) {}
+ DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
void emit(AsmPrinter &Asm, MCSection *StrSection,
MCSection *OffsetSection = nullptr);
OpenPOWER on IntegriCloud