[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp WriterInternals.h

Chris Lattner sabre at nondot.org
Sun Feb 11 21:18:29 PST 2007



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.cpp updated: 1.110 -> 1.111
Writer.cpp updated: 1.165 -> 1.166
WriterInternals.h updated: 1.32 -> 1.33
---
Log message:

Switch ValueSymbolTable to use StringMap<Value*> instead of std::map<std::string, Value*>
as its main datastructure.  There are many improvements yet to be made, but
this speeds up opt --std-compile-opts on 447.dealII by 7.3%.



---
Diffs of the changes:  (+11 -11)

 SlotCalculator.cpp |    2 +-
 Writer.cpp         |   15 ++++++---------
 WriterInternals.h  |    5 ++++-
 3 files changed, 11 insertions(+), 11 deletions(-)


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.110 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.111
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.110	Sat Feb 10 18:03:39 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Sun Feb 11 23:18:08 2007
@@ -199,7 +199,7 @@
 void SlotCalculator::processValueSymbolTable(const ValueSymbolTable *VST) {
   for (ValueSymbolTable::const_iterator VI = VST->begin(), VE = VST->end(); 
        VI != VE; ++VI)
-    CreateSlotIfNeeded(VI->second);
+    CreateSlotIfNeeded(VI->getValue());
 }
 
 void SlotCalculator::CreateSlotIfNeeded(const Value *V) {


Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.165 llvm/lib/Bytecode/Writer/Writer.cpp:1.166
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.165	Sat Feb 10 01:42:59 2007
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Sun Feb 11 23:18:08 2007
@@ -132,10 +132,9 @@
     output_vbr((unsigned)i << 1);          // Low order bit is clear.
 }
 
-inline void BytecodeWriter::output(const std::string &s) {
-  unsigned Len = s.length();
+inline void BytecodeWriter::output_str(const char *Str, unsigned Len) {
   output_vbr(Len);             // Strings may have an arbitrary length.
-  Out.insert(Out.end(), s.begin(), s.end());
+  Out.insert(Out.end(), Str, Str+Len);
 }
 
 inline void BytecodeWriter::output_data(const void *Ptr, const void *End) {
@@ -1088,14 +1087,12 @@
                             true/*ElideIfEmpty*/);
 
   // Organize the symbol table by type
-  typedef std::pair<const std::string*, const Value*> PlaneMapEntry;
-  typedef SmallVector<PlaneMapEntry, 8> PlaneMapVector;
+  typedef SmallVector<const ValueName*, 8> PlaneMapVector;
   typedef DenseMap<const Type*, PlaneMapVector > PlaneMap;
   PlaneMap Planes;
   for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
        SI != SE; ++SI) 
-    Planes[SI->second->getType()]
-      .push_back(std::make_pair(&SI->first, SI->second));
+    Planes[SI->getValue()->getType()].push_back(&*SI);
 
   for (PlaneMap::iterator PI = Planes.begin(), PE = Planes.end();
        PI != PE; ++PI) {
@@ -1113,8 +1110,8 @@
     // Write each of the values in this plane
     for (; I != End; ++I) {
       // Symtab entry: [def slot #][name]
-      output_vbr(Table.getSlot(I->second));
-      output(*I->first);
+      output_vbr(Table.getSlot((*I)->getValue()));
+      output_str((*I)->getKeyData(), (*I)->getKeyLength());
     }
   }
 }


Index: llvm/lib/Bytecode/Writer/WriterInternals.h
diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.32 llvm/lib/Bytecode/Writer/WriterInternals.h:1.33
--- llvm/lib/Bytecode/Writer/WriterInternals.h:1.32	Sat Feb 10 01:42:59 2007
+++ llvm/lib/Bytecode/Writer/WriterInternals.h	Sun Feb 11 23:18:08 2007
@@ -85,7 +85,10 @@
   /// @brief Signed 32-bit variable bit rate output primitive.
   inline void output_vbr(int i);
 
-  inline void output(const std::string &s);
+  inline void output_str(const char *Str, unsigned Len);
+  inline void output(const std::string &s) {
+    output_str(&s[0], s.size());
+  }
 
   inline void output_data(const void *Ptr, const void *End);
 






More information about the llvm-commits mailing list