aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-12 05:18:08 +0000
committerChris Lattner <sabre@nondot.org>2007-02-12 05:18:08 +0000
commitdec628eead87b20773c98a00830580df211acc98 (patch)
treecb28286b21387a97519f3e30c757c4fa07b904c5 /lib/Bytecode
parentfa48e9612e52adada82b3d74f9a8e2c35c960b36 (diff)
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%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp2
-rw-r--r--lib/Bytecode/Writer/Writer.cpp15
-rw-r--r--lib/Bytecode/Writer/WriterInternals.h5
3 files changed, 11 insertions, 11 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index 0c8ba48be7..43ad922e2b 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -199,7 +199,7 @@ void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *TST) {
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) {
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index b98604bf71..434703f92e 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -132,10 +132,9 @@ inline void BytecodeWriter::output_vbr(int i) {
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 @@ void BytecodeWriter::outputValueSymbolTable(const ValueSymbolTable &VST) {
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 @@ void BytecodeWriter::outputValueSymbolTable(const ValueSymbolTable &VST) {
// 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());
}
}
}
diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h
index 6a036d804a..747ad8ef06 100644
--- a/lib/Bytecode/Writer/WriterInternals.h
+++ b/lib/Bytecode/Writer/WriterInternals.h
@@ -85,7 +85,10 @@ private:
/// @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);