[llvm] r238112 - AsmPrinter: Refactor DwarfStringPool::getEntry(), NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Sun May 24 09:06:08 PDT 2015


Author: dexonsmith
Date: Sun May 24 11:06:08 2015
New Revision: 238112

URL: http://llvm.org/viewvc/llvm-project?rev=238112&view=rev
Log:
AsmPrinter: Refactor DwarfStringPool::getEntry(), NFC

Move `DwarfStringPool`'s `getEntry()` to the header (and make it a
member function) in preparation for calculating symbol offsets
on-the-fly.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp?rev=238112&r1=238111&r2=238112&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp Sun May 24 11:06:08 2015
@@ -12,10 +12,8 @@
 
 using namespace llvm;
 
-static std::pair<MCSymbol *, unsigned> &
-getEntry(AsmPrinter &Asm,
-         StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> &Pool,
-         StringRef Prefix, StringRef Str) {
+std::pair<MCSymbol *, unsigned> &DwarfStringPool::getEntry(AsmPrinter &Asm,
+                                                           StringRef Str) {
   std::pair<MCSymbol *, unsigned> &Entry = Pool[Str];
   if (!Entry.first) {
     Entry.second = Pool.size() - 1;
@@ -24,14 +22,6 @@ getEntry(AsmPrinter &Asm,
   return Entry;
 }
 
-MCSymbol *DwarfStringPool::getSymbol(AsmPrinter &Asm, StringRef Str) {
-  return getEntry(Asm, Pool, Prefix, Str).first;
-}
-
-unsigned DwarfStringPool::getIndex(AsmPrinter &Asm, StringRef Str) {
-  return getEntry(Asm, Pool, Prefix, Str).second;
-}
-
 void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
                            MCSection *OffsetSection) {
   if (Pool.empty())

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.h?rev=238112&r1=238111&r2=238112&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.h Sun May 24 11:06:08 2015
@@ -37,13 +37,20 @@ public:
 
   /// \brief Returns an entry into the string pool with the given
   /// string text.
-  MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str);
+  MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str) {
+    return getEntry(Asm, Str).first;
+  }
 
   /// \brief Returns the index into the string pool with the given
   /// string text.
-  unsigned getIndex(AsmPrinter &Asm, StringRef Str);
+  unsigned getIndex(AsmPrinter &Asm, StringRef Str) {
+    return getEntry(Asm, Str).second;
+  }
 
   bool empty() const { return Pool.empty(); }
+
+private:
+  std::pair<MCSymbol *, unsigned> &getEntry(AsmPrinter &Asm, StringRef Str);
 };
 }
 #endif





More information about the llvm-commits mailing list