summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-02-05 20:47:22 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-02-05 20:47:22 +0000
commit3aaaa0b2bd3825580647b7e0ee5045a8e32e0413 (patch)
tree2ca99bb6046e1441bf5af80fc1dff176ddc79a8c /llvm/lib/Bytecode/Writer/Writer.cpp
parente84cf921412069284266f02e8aa3fa18ca315e25 (diff)
downloadbcm5719-llvm-3aaaa0b2bd3825580647b7e0ee5045a8e32e0413.tar.gz
bcm5719-llvm-3aaaa0b2bd3825580647b7e0ee5045a8e32e0413.zip
For PR411:
This patch replaces the SymbolTable class with ValueSymbolTable which does not support types planes. This means that all symbol names in LLVM must now be unique. The patch addresses the necessary changes to deal with this and removes code no longer needed as a result. This completes the bulk of the changes for this PR. Some cleanup patches will follow. llvm-svn: 33918
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--llvm/lib/Bytecode/Writer/Writer.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index 0d4ccbddd69..a2e8fe566d3 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/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<std::string, const Value*> PlaneMapEntry;
+ typedef std::vector<PlaneMapEntry> PlaneMapVector;
+ typedef std::map<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));
+
+ 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
OpenPOWER on IntegriCloud