X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FBytecode%2FWriter%2FWriter.cpp;h=a2e8fe566d35633bfe55c7751ccb04126c0841bf;hb=ef9b9a793949469cdaa4ab6d0173136229dcab7b;hp=0d4ccbddd69e8dc5c3ebfbe74f0a4ae477b1e5d3;hpb=5cbf985dcbc89fba3208e7baf8b6f488b06d3ec9;p=oota-llvm.git diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 0d4ccbddd69..a2e8fe566d3 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -26,8 +26,8 @@ #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" #include "llvm/Module.h" -#include "llvm/SymbolTable.h" #include "llvm/TypeSymbolTable.h" +#include "llvm/ValueSymbolTable.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/Compressor.h" #include "llvm/Support/MathExtras.h" @@ -1144,21 +1144,31 @@ void BytecodeWriter::outputTypeSymbolTable(const TypeSymbolTable &TST) { } } -void BytecodeWriter::outputValueSymbolTable(const SymbolTable &MST) { +void BytecodeWriter::outputValueSymbolTable(const ValueSymbolTable &VST) { // Do not output the Bytecode block for an empty symbol table, it just wastes // space! - if (MST.isEmpty()) return; + if (VST.empty()) return; BytecodeBlock SymTabBlock(BytecodeFormat::ValueSymbolTableBlockID, *this, true/*ElideIfEmpty*/); - // Now do each of the type planes in order. - for (SymbolTable::plane_const_iterator PI = MST.plane_begin(), - PE = MST.plane_end(); PI != PE; ++PI) { - SymbolTable::value_const_iterator I = MST.value_begin(PI->first); - SymbolTable::value_const_iterator End = MST.value_end(PI->first); + // Organize the symbol table by type + typedef std::pair PlaneMapEntry; + typedef std::vector PlaneMapVector; + typedef std::map 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)); + + for (PlaneMap::const_iterator PI = Planes.begin(), PE = Planes.end(); + PI != PE; ++PI) { int Slot; + PlaneMapVector::const_iterator I = PI->second.begin(); + PlaneMapVector::const_iterator End = PI->second.end(); + if (I == End) continue; // Don't mess with an absent type... // Write the number of values in this plane