diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-24 16:33:33 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-24 16:33:33 +0000 |
commit | 03b7a1cf93b215ce99cd4eadfba3b08f3242a4db (patch) | |
tree | f780d73dc33532dbe9fa9d216deb42ee0fa1d214 /llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp | |
parent | 0b223598587590dbf52ec7b0842a69e65b5a8f3a (diff) | |
download | llvm-03b7a1cf93b215ce99cd4eadfba3b08f3242a4db.zip llvm-03b7a1cf93b215ce99cd4eadfba3b08f3242a4db.tar.gz llvm-03b7a1cf93b215ce99cd4eadfba3b08f3242a4db.tar.bz2 |
AsmPrinter: Extract DwarfStringPoolEntry from DwarfStringPool, NFC
Extract out `DwarfStringPoolEntry` and `DwarfStringPoolRef` from
`DwarfStringPool` so that downstream users can start using
`DwarfStringPool::getEntry()` directly. This will allow users to delay
the decision between emitting a symbol or an offset until later.
llvm-svn: 238116
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp index a599126..9dd233a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp @@ -12,10 +12,11 @@ using namespace llvm; -DwarfStringPool::EntryTy &DwarfStringPool::getEntry(AsmPrinter &Asm, +DwarfStringPool::EntryRef DwarfStringPool::getEntry(AsmPrinter &Asm, StringRef Str) { - auto &Entry = Pool[Str]; - if (!Entry.Symbol) { + auto I = Pool.insert(std::make_pair(Str, EntryTy())); + if (I.second) { + auto &Entry = I.first->second; Entry.Index = Pool.size() - 1; Entry.Offset = NumBytes; Entry.Symbol = Asm.createTempSymbol(Prefix); @@ -23,7 +24,7 @@ DwarfStringPool::EntryTy &DwarfStringPool::getEntry(AsmPrinter &Asm, NumBytes += Str.size() + 1; assert(NumBytes > Entry.Offset && "Unexpected overflow"); } - return Entry; + return EntryRef(*I.first); } void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection, |