summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Bytecode/Format.h5
-rw-r--r--include/llvm/Function.h4
-rw-r--r--include/llvm/Module.h12
-rw-r--r--include/llvm/SymbolTable.h52
-rw-r--r--include/llvm/TypeSymbolTable.h4
-rw-r--r--lib/AsmParser/llvmAsmParser.cpp.cvs8
-rw-r--r--lib/AsmParser/llvmAsmParser.y8
-rw-r--r--lib/AsmParser/llvmAsmParser.y.cvs8
-rw-r--r--lib/Bytecode/Reader/Analyzer.cpp10
-rw-r--r--lib/Bytecode/Reader/Reader.cpp47
-rw-r--r--lib/Bytecode/Reader/Reader.h8
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp36
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h4
-rw-r--r--lib/Bytecode/Writer/Writer.cpp35
-rw-r--r--lib/Bytecode/Writer/WriterInternals.h4
-rw-r--r--lib/Linker/LinkModules.cpp40
-rw-r--r--lib/Target/CBackend/CBackend.cpp23
-rw-r--r--lib/Target/CBackend/Writer.cpp23
-rw-r--r--lib/Transforms/IPO/DeadTypeElimination.cpp9
-rw-r--r--lib/Transforms/IPO/StripSymbols.cpp7
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp10
-rw-r--r--lib/VMCore/AsmWriter.cpp28
-rw-r--r--lib/VMCore/Function.cpp4
-rw-r--r--lib/VMCore/Module.cpp27
-rw-r--r--lib/VMCore/SymbolTable.cpp110
-rw-r--r--lib/VMCore/SymbolTableListTraitsImpl.h12
-rw-r--r--lib/VMCore/TypeSymbolTable.cpp8
-rw-r--r--lib/VMCore/Value.cpp8
-rw-r--r--lib/VMCore/Verifier.cpp12
-rw-r--r--tools/bugpoint/CrashDebugger.cpp2
-rw-r--r--tools/llvm2cpp/CppWriter.cpp17
31 files changed, 241 insertions, 344 deletions
diff --git a/include/llvm/Bytecode/Format.h b/include/llvm/Bytecode/Format.h
index 562d8ff011..fc896b895d 100644
--- a/include/llvm/Bytecode/Format.h
+++ b/include/llvm/Bytecode/Format.h
@@ -35,7 +35,7 @@ public:
ModuleBlockID = 1, ///< Module block that contains other blocks.
FunctionBlockID = 2, ///< Function block identifier
ConstantPoolBlockID = 3, ///< Constant pool identifier
- SymbolTableBlockID = 4, ///< Symbol table identifier
+ ValueSymbolTableBlockID= 4, ///< Value Symbol table identifier
ModuleGlobalInfoBlockID= 5, ///< Module global info identifier
GlobalTypePlaneBlockID = 6, ///< Global type plan identifier
InstructionListBlockID = 7, ///< All instructions in a function
@@ -46,8 +46,9 @@ public:
/// instructions to be encoded more efficiently because VBR takes fewer
/// bytes with smaller values.
/// @brief Value Compaction Table Block
- CompactionTableBlockID = 0x08,
+ CompactionTableBlockID = 8,
+ TypeSymbolTableBlockID = 9, ///< Value Symbol table identifier
// Not a block id, just used to count them
NumberOfBlockIDs
};
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 7346c3b3e3..a31e7f4834 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -163,8 +163,8 @@ public:
/// getSymbolTable() - Return the symbol table...
///
- inline SymbolTable &getSymbolTable() { return *SymTab; }
- inline const SymbolTable &getSymbolTable() const { return *SymTab; }
+ inline SymbolTable &getValueSymbolTable() { return *SymTab; }
+ inline const SymbolTable &getValueSymbolTable() const { return *SymTab; }
//===--------------------------------------------------------------------===//
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index 42214af1ac..e5c157be95 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -25,6 +25,7 @@ class GlobalVariable;
class GlobalValueRefMap; // Used by ConstantVals.cpp
class FunctionType;
class SymbolTable;
+class TypeSymbolTable;
template<> struct ilist_traits<Function>
: public SymbolTableListTraits<Function, Module, Module> {
@@ -91,7 +92,8 @@ private:
FunctionListType FunctionList; ///< The Functions in the module
LibraryListType LibraryList; ///< The Libraries needed by the module
std::string GlobalScopeAsm; ///< Inline Asm at global scope.
- SymbolTable *SymTab; ///< Symbol Table for the module
+ SymbolTable *ValSymTab; ///< Symbol table for values
+ TypeSymbolTable *TypeSymTab; ///< Symbol table for types
std::string ModuleID; ///< Human readable identifier for the module
std::string TargetTriple; ///< Platform target triple Module compiled on
std::string DataLayout; ///< Target data description
@@ -237,9 +239,13 @@ public:
/// Get the Module's list of functions.
FunctionListType &getFunctionList() { return FunctionList; }
/// Get the symbol table of global variable and function identifiers
- const SymbolTable &getSymbolTable() const { return *SymTab; }
+ const SymbolTable &getValueSymbolTable() const { return *ValSymTab; }
/// Get the Module's symbol table of global variable and function identifiers.
- SymbolTable &getSymbolTable() { return *SymTab; }
+ SymbolTable &getValueSymbolTable() { return *ValSymTab; }
+ /// Get the symbol table of types
+ const TypeSymbolTable &getTypeSymbolTable() const { return *TypeSymTab; }
+ /// Get the Module's symbol table of types
+ TypeSymbolTable &getTypeSymbolTable() { return *TypeSymTab; }
/// @}
/// @name Global Variable Iteration
diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h
index 52a2c29ea7..6451f9c8e2 100644
--- a/include/llvm/SymbolTable.h
+++ b/include/llvm/SymbolTable.h
@@ -47,16 +47,6 @@ class SymbolTable : public AbstractTypeUser {
/// @name Types
/// @{
public:
-
- /// @brief A mapping of names to types.
- typedef std::map<const std::string, const Type*> TypeMap;
-
- /// @brief An iterator over the TypeMap.
- typedef TypeMap::iterator type_iterator;
-
- /// @brief A const_iterator over the TypeMap.
- typedef TypeMap::const_iterator type_const_iterator;
-
/// @brief A mapping of names to values.
typedef std::map<const std::string, Value *> ValueMap;
@@ -96,20 +86,10 @@ public:
/// @brief Lookup a named, typed value.
Value *lookup(const Type *Ty, const std::string &name) const;
- /// This method finds the type with the given \p name in the
- /// type map and returns it.
- /// @returns null if the name is not found, otherwise the Type
- /// associated with the \p name.
- /// @brief Lookup a type by name.
- Type* lookupType(const std::string& name) const;
-
/// @returns true iff the type map and the type plane are both not
/// empty.
/// @brief Determine if the symbol table is empty
- inline bool isEmpty() const { return pmap.empty() && tmap.empty(); }
-
- /// @brief The number of name/type pairs is returned.
- inline unsigned num_types() const { return unsigned(tmap.size()); }
+ inline bool isEmpty() const { return pmap.empty(); }
/// Given a base name, return a string that is either equal to it or
/// derived from it that does not already occur in the symbol table
@@ -178,20 +158,6 @@ public:
return pmap.find(Typ)->second.end();
}
- /// Get an iterator to the start of the name/Type map.
- inline type_iterator type_begin() { return tmap.begin(); }
-
- /// @brief Get a const_iterator to the start of the name/Type map.
- inline type_const_iterator type_begin() const { return tmap.begin(); }
-
- /// Get an iterator to the end of the name/Type map. This serves as the
- /// marker for end of iteration of the types.
- inline type_iterator type_end() { return tmap.end(); }
-
- /// Get a const-iterator to the end of the name/Type map. This serves
- /// as the marker for end of iteration of the types.
- inline type_const_iterator type_end() const { return tmap.end(); }
-
/// This method returns a plane_const_iterator for iteration over
/// the type planes starting at a specific plane, given by \p Ty.
/// @brief Find a type plane.
@@ -219,16 +185,6 @@ public:
/// @brief Strip the symbol table.
bool strip();
- /// Inserts a type into the symbol table with the specified name. There can be
- /// a many-to-one mapping between names and types. This method allows a type
- /// with an existing entry in the symbol table to get a new name.
- /// @brief Insert a type under a new name.
- void insert(const std::string &Name, const Type *Typ);
-
- /// Remove a type at the specified position in the symbol table.
- /// @returns the removed Type.
- Type* remove(type_iterator TI);
-
/// @}
/// @name Mutators used by Value::setName and other LLVM internals.
/// @{
@@ -286,15 +242,9 @@ private:
/// @brief The mapping of types to names to values.
PlaneMap pmap;
- /// This is the type plane. It is separated from the pmap
- /// because the elements of the map are name/Type pairs not
- /// name/Value pairs and Type is not a Value.
- TypeMap tmap;
-
/// This value is used to retain the last unique value used
/// by getUniqueName to generate unique names.
mutable uint32_t LastUnique;
-
/// @}
};
diff --git a/include/llvm/TypeSymbolTable.h b/include/llvm/TypeSymbolTable.h
index c9f8d3107b..b95415377e 100644
--- a/include/llvm/TypeSymbolTable.h
+++ b/include/llvm/TypeSymbolTable.h
@@ -111,12 +111,12 @@ public:
/// Remove a type at the specified position in the symbol table.
/// @returns the removed Type.
/// @returns the Type that was erased from the symbol table.
- Type* erase(iterator TI);
+ Type* remove(iterator TI);
/// Remove a specific Type from the symbol table. This isn't fast, linear
/// search, O(n), algorithm.
/// @returns true if the erase was successful (TI was found)
- bool erase(Type* TI);
+ bool remove(Type* TI);
/// Rename a type. This ain't fast, we have to linearly search for it first.
/// @returns true if the rename was successful (type was found)
diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs
index e78dc6fe12..ebbffeb7ab 100644
--- a/lib/AsmParser/llvmAsmParser.cpp.cvs
+++ b/lib/AsmParser/llvmAsmParser.cpp.cvs
@@ -639,8 +639,8 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
SymbolTable &SymTab =
- inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
- CurModule.CurrentModule->getSymbolTable();
+ inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
+ CurModule.CurrentModule->getValueSymbolTable();
return SymTab.lookup(Ty, Name);
}
@@ -821,7 +821,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
case ValID::NameVal: // Is it a named definition?
Name = ID.Name;
if (Value *N = CurFun.CurrentFunction->
- getSymbolTable().lookup(Type::LabelTy, Name))
+ getValueSymbolTable().lookup(Type::LabelTy, Name))
BB = cast<BasicBlock>(N);
break;
}
@@ -961,7 +961,7 @@ static void setValueName(Value *V, char *NameStr) {
}
assert(inFunctionScope() && "Must be in function scope!");
- SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
+ SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
if (ST.lookup(V->getType(), Name)) {
GenerateError("Redefinition of value '" + Name + "' of type '" +
V->getType()->getDescription() + "'!");
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 0059531518..192b560819 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -311,8 +311,8 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
SymbolTable &SymTab =
- inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
- CurModule.CurrentModule->getSymbolTable();
+ inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
+ CurModule.CurrentModule->getValueSymbolTable();
return SymTab.lookup(Ty, Name);
}
@@ -493,7 +493,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
case ValID::NameVal: // Is it a named definition?
Name = ID.Name;
if (Value *N = CurFun.CurrentFunction->
- getSymbolTable().lookup(Type::LabelTy, Name))
+ getValueSymbolTable().lookup(Type::LabelTy, Name))
BB = cast<BasicBlock>(N);
break;
}
@@ -633,7 +633,7 @@ static void setValueName(Value *V, char *NameStr) {
}
assert(inFunctionScope() && "Must be in function scope!");
- SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
+ SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
if (ST.lookup(V->getType(), Name)) {
GenerateError("Redefinition of value '" + Name + "' of type '" +
V->getType()->getDescription() + "'!");
diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs
index 0059531518..192b560819 100644
--- a/lib/AsmParser/llvmAsmParser.y.cvs
+++ b/lib/AsmParser/llvmAsmParser.y.cvs
@@ -311,8 +311,8 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
SymbolTable &SymTab =
- inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
- CurModule.CurrentModule->getSymbolTable();
+ inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
+ CurModule.CurrentModule->getValueSymbolTable();
return SymTab.lookup(Ty, Name);
}
@@ -493,7 +493,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
case ValID::NameVal: // Is it a named definition?
Name = ID.Name;
if (Value *N = CurFun.CurrentFunction->
- getSymbolTable().lookup(Type::LabelTy, Name))
+ getValueSymbolTable().lookup(Type::LabelTy, Name))
BB = cast<BasicBlock>(N);
break;
}
@@ -633,7 +633,7 @@ static void setValueName(Value *V, char *NameStr) {
}
assert(inFunctionScope() && "Must be in function scope!");
- SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
+ SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
if (ST.lookup(V->getType(), Name)) {
GenerateError("Redefinition of value '" + Name + "' of type '" +
V->getType()->getDescription() + "'!");
diff --git a/lib/Bytecode/Reader/Analyzer.cpp b/lib/Bytecode/Reader/Analyzer.cpp
index 078360249c..899a534272 100644
--- a/lib/Bytecode/Reader/Analyzer.cpp
+++ b/lib/Bytecode/Reader/Analyzer.cpp
@@ -96,11 +96,12 @@ public:
bca.BlockSizes[BytecodeFormat::ModuleBlockID] = theSize;
bca.BlockSizes[BytecodeFormat::FunctionBlockID] = 0;
bca.BlockSizes[BytecodeFormat::ConstantPoolBlockID] = 0;
- bca.BlockSizes[BytecodeFormat::SymbolTableBlockID] = 0;
+ bca.BlockSizes[BytecodeFormat::ValueSymbolTableBlockID] = 0;
bca.BlockSizes[BytecodeFormat::ModuleGlobalInfoBlockID] = 0;
bca.BlockSizes[BytecodeFormat::GlobalTypePlaneBlockID] = 0;
bca.BlockSizes[BytecodeFormat::InstructionListBlockID] = 0;
bca.BlockSizes[BytecodeFormat::CompactionTableBlockID] = 0;
+ bca.BlockSizes[BytecodeFormat::TypeSymbolTableBlockID] = 0;
}
virtual void handleFinish() {
@@ -636,8 +637,11 @@ void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out )
print(Out, "Compaction Table Bytes",
double(bca.BlockSizes[BytecodeFormat::CompactionTableBlockID]),
double(bca.byteSize));
- print(Out, "Symbol Table Bytes",
- double(bca.BlockSizes[BytecodeFormat::SymbolTableBlockID]),
+ print(Out, "Value Symbol Table Bytes",
+ double(bca.BlockSizes[BytecodeFormat::ValueSymbolTableBlockID]),
+ double(bca.byteSize));
+ print(Out, "Type Symbol Table Bytes",
+ double(bca.BlockSizes[BytecodeFormat::TypeSymbolTableBlockID]),
double(bca.byteSize));
print(Out, "Alignment Bytes",
double(bca.numAlignment), double(bca.byteSize));
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index afff24adb6..b1e4bf639c 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -24,6 +24,7 @@
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Bytecode/Format.h"
#include "llvm/Config/alloca.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
@@ -1023,13 +1024,27 @@ unsigned BytecodeReader::ParseInstructionList(Function* F) {
return BlockNo;
}
-/// Parse a symbol table. This works for both module level and function
+/// Parse a type symbol table.
+void BytecodeReader::ParseTypeSymbolTable(TypeSymbolTable *TST) {
+ // Type Symtab block header: [num entries]
+ unsigned NumEntries = read_vbr_uint();
+ for (unsigned i = 0; i < NumEntries; ++i) {
+ // Symtab entry: [type slot #][name]
+ unsigned slot = read_vbr_uint();
+ std::string Name = read_str();
+ const Type* T = getType(slot);
+ TST->insert(Name, T);
+ }
+}
+
+/// Parse a value symbol table. This works for both module level and function
/// level symbol tables. For function level symbol tables, the CurrentFunction
/// parameter must be non-zero and the ST parameter must correspond to
/// CurrentFunction's symbol table. For Module level symbol tables, the
/// CurrentFunction argument must be zero.
-void BytecodeReader::ParseSymbolTable(Function *CurrentFunction,
- SymbolTable *ST) {
+void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
+ SymbolTable *ST) {
+
if (Handler) Handler->handleSymbolTableBegin(CurrentFunction,ST);
// Allow efficient basic block lookup by number.
@@ -1039,16 +1054,6 @@ void BytecodeReader::ParseSymbolTable(Function *CurrentFunction,
E = CurrentFunction->end(); I != E; ++I)
BBMap.push_back(I);
- // Symtab block header: [num entries]
- unsigned NumEntries = read_vbr_uint();
- for (unsigned i = 0; i < NumEntries; ++i) {
- // Symtab entry: [def slot #][name]
- unsigned slot = read_vbr_uint();
- std::string Name = read_str();
- const Type* T = getType(slot);
- ST->insert(Name, T);
- }
-
while (moreInBlock()) {
// Symtab block header: [num entries][type id number]
unsigned NumEntries = read_vbr_uint();
@@ -1683,8 +1688,12 @@ void BytecodeReader::ParseFunctionBody(Function* F) {
break;
}
- case BytecodeFormat::SymbolTableBlockID:
- ParseSymbolTable(F, &F->getSymbolTable());
+ case BytecodeFormat::ValueSymbolTableBlockID:
+ ParseValueSymbolTable(F, &F->getValueSymbolTable());
+ break;
+
+ case BytecodeFormat::TypeSymbolTableBlockID:
+ error("Functions don't have type symbol tables");
break;
default:
@@ -2084,8 +2093,12 @@ void BytecodeReader::ParseModule() {
ParseFunctionLazily();
break;
- case BytecodeFormat::SymbolTableBlockID:
- ParseSymbolTable(0, &TheModule->getSymbolTable());
+ case BytecodeFormat::ValueSymbolTableBlockID:
+ ParseValueSymbolTable(0, &TheModule->getValueSymbolTable());
+ break;
+
+ case BytecodeFormat::TypeSymbolTableBlockID:
+ ParseTypeSymbolTable(&TheModule->getTypeSymbolTable());
break;
default:
diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h
index 1d2fe32af6..677c39f99f 100644
--- a/lib/Bytecode/Reader/Reader.h
+++ b/lib/Bytecode/Reader/Reader.h
@@ -29,6 +29,7 @@
namespace llvm {
class BytecodeHandler; ///< Forward declare the handler interface
+class TypeSymbolTable; ///< Forward declare
/// This class defines the interface for parsing a buffer of bytecode. The
/// parser itself takes no action except to call the various functions of
@@ -199,8 +200,11 @@ protected:
/// @brief Parse the ModuleGlobalInfo block
void ParseModuleGlobalInfo();
- /// @brief Parse a symbol table
- void ParseSymbolTable( Function* Func, SymbolTable *ST);
+ /// @brief Parse a value symbol table
+ void ParseTypeSymbolTable(TypeSymbolTable *ST);
+
+ /// @brief Parse a value symbol table
+ void ParseValueSymbolTable(Function* Func, SymbolTable *ST);
/// @brief Parse functions lazily.
void ParseFunctionLazily();
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index cf770c4bbc..fdf7174b85 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -22,6 +22,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Type.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/ADT/PostOrderIterator.h"
@@ -189,13 +190,14 @@ void SlotCalculator::processModule() {
}
getOrCreateSlot(I->getType());
}
- processSymbolTableConstants(&F->getSymbolTable());
+ processSymbolTableConstants(&F->getValueSymbolTable());
}
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
SC_DEBUG("Inserting SymbolTable values:\n");
- processSymbolTable(&TheModule->getSymbolTable());
+ processTypeSymbolTable(&TheModule->getTypeSymbolTable());
+ processValueSymbolTable(&TheModule->getValueSymbolTable());
// Now that we have collected together all of the information relevant to the
// module, compactify the type table if it is particularly big and outputting
@@ -233,16 +235,18 @@ void SlotCalculator::processModule() {
SC_DEBUG("end processModule!\n");
}
+// processTypeSymbolTable - Insert all of the type sin the specified symbol
+// table.
+void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *ST) {
+ for (TypeSymbolTable::const_iterator TI = ST->begin(), TE = ST->end();
+ TI != TE; ++TI )
+ getOrCreateSlot(TI->second);
+}
+
// processSymbolTable - Insert all of the values in the specified symbol table
// into the values table...
//
-void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
- // Do the types first.
- for (SymbolTable::type_const_iterator TI = ST->type_begin(),
- TE = ST->type_end(); TI != TE; ++TI )
- getOrCreateSlot(TI->second);
-
- // Now do the values.
+void SlotCalculator::processValueSymbolTable(const SymbolTable *ST) {
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
PE = ST->plane_end(); PI != PE; ++PI)
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
@@ -251,11 +255,6 @@ void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
}
void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
- // Do the types first
- for (SymbolTable::type_const_iterator TI = ST->type_begin(),
- TE = ST->type_end(); TI != TE; ++TI )
- getOrCreateSlot(TI->second);
-
// Now do the constant values in all planes
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
PE = ST->plane_end(); PI != PE; ++PI)
@@ -306,7 +305,7 @@ void SlotCalculator::incorporateFunction(const Function *F) {
// symbol table references to constants not in the output. Scan for these
// constants now.
//
- processSymbolTableConstants(&F->getSymbolTable());
+ processSymbolTableConstants(&F->getValueSymbolTable());
}
SC_DEBUG("Inserting Instructions:\n");
@@ -468,13 +467,8 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
getOrCreateCompactionTableSlot(I->getOperand(op));
}
- // Do the types in the symbol table
- const SymbolTable &ST = F->getSymbolTable();
- for (SymbolTable::type_const_iterator TI = ST.type_begin(),
- TE = ST.type_end(); TI != TE; ++TI)
- getOrCreateCompactionTableSlot(TI->second);
-
// Now do the constants and global values
+ const SymbolTable &ST = F->getValueSymbolTable();
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
PE = ST.plane_end(); PI != PE; ++PI)
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index e88a88f726..405c0edbd3 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -30,6 +30,7 @@ class Type;
class Module;
class Function;
class SymbolTable;
+class TypeSymbolTable;
class ConstantArray;
class SlotCalculator {
@@ -168,7 +169,8 @@ private:
// processSymbolTable - Insert all of the values in the specified symbol table
// into the values table...
//
- void processSymbolTable(const SymbolTable *ST);
+ void processTypeSymbolTable(const TypeSymbolTable *ST);
+ void processValueSymbolTable(const SymbolTable *ST);
void processSymbolTableConstants(const SymbolTable *ST);
void buildCompactionTable(const Function *F);
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 58cc13a141..37e4abfae2 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -27,6 +27,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/Compressor.h"
#include "llvm/Support/MathExtras.h"
@@ -837,8 +838,11 @@ BytecodeWriter::BytecodeWriter(std::vector<unsigned char> &o, const Module *M)
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
outputFunction(I);
- // If needed, output the symbol table for the module...
- outputSymbolTable(M->getSymbolTable());
+ // Output the symbole table for types
+ outputTypeSymbolTable(M->getTypeSymbolTable());
+
+ // Output the symbol table for values
+ outputValueSymbolTable(M->getValueSymbolTable());
}
void BytecodeWriter::outputTypes(unsigned TypeNum) {
@@ -1112,7 +1116,7 @@ void BytecodeWriter::outputFunction(const Function *F) {
outputInstructions(F);
// If needed, output the symbol table for the function...
- outputSymbolTable(F->getSymbolTable());
+ outputValueSymbolTable(F->getValueSymbolTable());
Table.purgeFunction();
}
@@ -1187,24 +1191,33 @@ void BytecodeWriter::outputCompactionTable() {
}
}
-void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
- // Do not output the Bytecode block for an empty symbol table, it just wastes
+void BytecodeWriter::outputTypeSymbolTable(const TypeSymbolTable &TST) {
+ // Do not output the block for an empty symbol table, it just wastes
// space!
- if (MST.isEmpty()) return;
+ if (TST.empty()) return;
- BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTableBlockID, *this,
+ // Create a header for the symbol table
+ BytecodeBlock SymTabBlock(BytecodeFormat::TypeSymbolTableBlockID, *this,
true/*ElideIfEmpty*/);
-
// Write the number of types
- output_vbr(MST.num_types());
+ output_vbr(TST.size());
// Write each of the types
- for (SymbolTable::type_const_iterator TI = MST.type_begin(),
- TE = MST.type_end(); TI != TE; ++TI) {
+ for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
+ TI != TE; ++TI) {
// Symtab entry:[def slot #][name]
output_typeid((unsigned)Table.getSlot(TI->second));
output(TI->first);
}
+}
+
+void BytecodeWriter::outputValueSymbolTable(const SymbolTable &MST) {
+ // Do not output the Bytecode block for an empty symbol table, it just wastes
+ // space!
+ if (MST.isEmpty()) 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(),
diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h
index f8c276e858..c518c01b94 100644
--- a/lib/Bytecode/Writer/WriterInternals.h
+++ b/lib/Bytecode/Writer/WriterInternals.h
@@ -25,6 +25,7 @@
namespace llvm {
class InlineAsm;
+ class TypeSymbolTable;
class BytecodeWriter {
std::vector<unsigned char> &Out;
@@ -64,7 +65,8 @@ private:
unsigned Type) ;
void outputModuleInfoBlock(const Module *C);
- void outputSymbolTable(const SymbolTable &ST);
+ void outputTypeSymbolTable(const TypeSymbolTable &TST);
+ void outputValueSymbolTable(const SymbolTable &ST);
void outputTypes(unsigned StartNo);
void outputConstantsInPlane(const std::vector<const Value*> &Plane,
unsigned StartNo);
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 9346c11824..4e298898b1 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -21,6 +21,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Instructions.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/Streams.h"
@@ -61,7 +62,7 @@ static std::string ToStr(const Type *Ty, const Module *M) {
// false - No errors.
//
static bool ResolveTypes(const Type *DestTy, const Type *SrcTy,
- SymbolTable *DestST, const std::string &Name) {
+ TypeSymbolTable *DestST, const std::string &Name) {
if (DestTy == SrcTy) return false; // If already equal, noop
// Does the type already exist in the module?
@@ -93,7 +94,8 @@ static const StructType *getST(const PATypeHolder &TH) {
// are compatible.
static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
const PATypeHolder &SrcTy,
- SymbolTable *DestST, const std::string &Name,
+ TypeSymbolTable *DestST,
+ const std::string &Name,
std::vector<std::pair<PATypeHolder, PATypeHolder> > &Pointers) {
const Type *SrcTyT = SrcTy.get();
const Type *DestTyT = DestTy.get();
@@ -164,7 +166,8 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
static bool RecursiveResolveTypes(const PATypeHolder &DestTy,
const PATypeHolder &SrcTy,
- SymbolTable *DestST, const std::string &Name){
+ TypeSymbolTable *DestST,
+ const std::string &Name){
std::vector<std::pair<PATypeHolder, PATypeHolder> > PointerTypes;
return RecursiveResolveTypesI(DestTy, SrcTy, DestST, Name, PointerTypes);
}
@@ -174,12 +177,12 @@ static bool RecursiveResolveTypes(const PATypeHolder &DestTy,
// types are named in the src module that are not named in the Dst module.
// Make sure there are no type name conflicts.
static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
- SymbolTable *DestST = &Dest->getSymbolTable();
- const SymbolTable *SrcST = &Src->getSymbolTable();
+ TypeSymbolTable *DestST = &Dest->getTypeSymbolTable();
+ const TypeSymbolTable *SrcST = &Src->getTypeSymbolTable();
// Look for a type plane for Type's...
- SymbolTable::type_const_iterator TI = SrcST->type_begin();
- SymbolTable::type_const_iterator TE = SrcST->type_end();
+ TypeSymbolTable::const_iterator TI = SrcST->begin();
+ TypeSymbolTable::const_iterator TE = SrcST->end();
if (TI == TE) return false; // No named types, do nothing.
// Some types cannot be resolved immediately because they depend on other
@@ -192,7 +195,7 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
const Type *RHS = TI->second;
// Check to see if this type name is already in the dest module...
- Type *Entry = DestST->lookupType(Name);
+ Type *Entry = DestST->lookup(Name);
if (ResolveTypes(Entry, RHS, DestST, Name)) {
// They look different, save the types 'till later to resolve.
@@ -208,8 +211,8 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
// Try direct resolution by name...
for (unsigned i = 0; i != DelayedTypesToResolve.size(); ++i) {
const std::string &Name = DelayedTypesToResolve[i];
- Type *T1 = SrcST->lookupType(Name);
- Type *T2 = DestST->lookupType(Name);
+ Type *T1 = SrcST->lookup(Name);
+ Type *T2 = DestST->lookup(Name);
if (!ResolveTypes(T2, T1, DestST, Name)) {
// We are making progress!
DelayedTypesToResolve.erase(DelayedTypesToResolve.begin()+i);
@@ -223,8 +226,8 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) {
// two types: { int* } and { opaque* }
for (unsigned i = 0, e = DelayedTypesToResolve.size(); i != e; ++i) {
const std::string &Name = DelayedTypesToResolve[i];
- PATypeHolder T1(SrcST->lookupType(Name));
- PATypeHolder T2(DestST->lookupType(Name));
+ PATypeHolder T1(SrcST->lookup(Name));
+ PATypeHolder T2(DestST->lookup(Name));
if (!RecursiveResolveTypes(T2, T1, DestST, Name)) {
// We are making progress!
@@ -326,7 +329,7 @@ static Value *RemapOperand(const Value *In,
/// through the trouble to force this back.
static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
assert(GV->getName() != Name && "Can't force rename to self");
- SymbolTable &ST = GV->getParent()->getSymbolTable();
+ SymbolTable &ST = GV->getParent()->getValueSymbolTable();
// If there is a conflict, rename the conflict.
Value *ConflictVal = ST.lookup(GV->getType(), Name);
@@ -427,7 +430,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
std::string *Err) {
// We will need a module level symbol table if the src module has a module
// level symbol table...
- SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable();
+ TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
// Loop over all of the globals in the src module, mapping them over as we go
for (Module::global_iterator I = Src->global_begin(), E = Src->global_end();
@@ -444,7 +447,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
DGV = dyn_cast<GlobalVariable>(EGV->second);
if (DGV)
// If types don't agree due to opaque types, try to resolve them.
- RecursiveResolveTypes(SGV->getType(), DGV->getType(),ST, "");
+ RecursiveResolveTypes(SGV->getType(), DGV->getType(), TST, "");
}
if (DGV && DGV->hasInternalLinkage())
@@ -591,9 +594,10 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
//
static bool LinkFunctionProtos(Module *Dest, const Module *Src,
std::map<const Value*, Value*> &ValueMap,
- std::map<std::string, GlobalValue*> &GlobalsByName,
+ std::map<std::string,
+ GlobalValue*> &GlobalsByName,
std::string *Err) {
- SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable();
+ TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
// Loop over all of the functions in the src module, mapping them over as we
// go
@@ -607,7 +611,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
GlobalsByName.find(SF->getName());
if (EF != GlobalsByName.end())
DF = dyn_cast<Function>(EF->second);
- if (DF && RecursiveResolveTypes(SF->getType(), DF->getType(), ST, ""))
+ if (DF && RecursiveResolveTypes(SF->getType(), DF->getType(), TST, ""))
DF = 0; // FIXME: gross.
}
}
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index bb9f801b8a..35ee1a74e5 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -21,6 +21,7 @@
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/InlineAsm.h"
@@ -136,7 +137,7 @@ namespace {
void lowerIntrinsics(Function &F);
void printModule(Module *M);
- void printModuleTypes(const SymbolTable &ST);
+ void printModuleTypes(const TypeSymbolTable &ST);
void printContainedStructs(const Type *Ty, std::set<const StructType *> &);
void printFloatingPointConstants(Function &F);
void printFunctionSignature(const Function *F, bool Prototype);
@@ -263,15 +264,15 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
// Loop over the module symbol table, removing types from UT that are
// already named, and removing names for types that are not used.
//
- SymbolTable &MST = M.getSymbolTable();
- for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
+ TypeSymbolTable &TST = M.getTypeSymbolTable();
+ for (TypeSymbolTable::iterator TI = TST.begin(), TE = TST.end();
TI != TE; ) {
- SymbolTable::type_iterator I = TI++;
+ TypeSymbolTable::iterator I = TI++;
// If this is not used, remove it from the symbol table.
std::set<const Type *>::iterator UTI = UT.find(I->second);
if (UTI == UT.end())
- MST.remove(I);
+ TST.remove(I);
else
UT.erase(UTI); // Only keep one name for this type.
}
@@ -1421,7 +1422,7 @@ bool CWriter::doInitialization(Module &M) {
//
// Loop over the symbol table, emitting all named constants...
- printModuleTypes(M.getSymbolTable());
+ printModuleTypes(M.getTypeSymbolTable());
// Global variable declarations...
if (!M.global_empty()) {
@@ -1589,7 +1590,7 @@ void CWriter::printFloatingPointConstants(Function &F) {
/// printSymbolTable - Run through symbol table looking for type names. If a
/// type name is found, emit its declaration...
///
-void CWriter::printModuleTypes(const SymbolTable &ST) {
+void CWriter::printModuleTypes(const TypeSymbolTable &TST) {
Out << "/* Helper union for bitcasts */\n";
Out << "typedef union {\n";
Out << " unsigned int Int32;\n";
@@ -1599,8 +1600,8 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
Out << "} llvmBitCastUnion;\n";
// We are only interested in the type plane of the symbol table.
- SymbolTable::type_const_iterator I = ST.type_begin();
- SymbolTable::type_const_iterator End = ST.type_end();
+ TypeSymbolTable::const_iterator I = TST.begin();
+ TypeSymbolTable::const_iterator End = TST.end();
// If there are no type names, exit early.
if (I == End) return;
@@ -1618,7 +1619,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// Now we can print out typedefs...
Out << "/* Typedefs */\n";
- for (I = ST.type_begin(); I != End; ++I) {
+ for (I = TST.begin(); I != End; ++I) {
const Type *Ty = cast<Type>(I->second);
std::string Name = "l_" + Mang->makeNameProper(I->first);
Out << "typedef ";
@@ -1635,7 +1636,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// printed in the correct order.
//
Out << "/* Structure contents */\n";
- for (I = ST.type_begin(); I != End; ++I)
+ for (I = TST.begin(); I != End; ++I)
if (const StructType *STy = dyn_cast<StructType>(I->second))
// Only print out used types!
printContainedStructs(STy, StructPrinted);
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index bb9f801b8a..35ee1a74e5 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -21,6 +21,7 @@
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/InlineAsm.h"
@@ -136,7 +137,7 @@ namespace {
void lowerIntrinsics(Function &F);
void printModule(Module *M);
- void printModuleTypes(const SymbolTable &ST);
+ void printModuleTypes(const TypeSymbolTable &ST);
void printContainedStructs(const Type *Ty, std::set<const StructType *> &);
void printFloatingPointConstants(Function &F);
void printFunctionSignature(const Function *F, bool Prototype);
@@ -263,15 +264,15 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
// Loop over the module symbol table, removing types from UT that are
// already named, and removing names for types that are not used.
//
- SymbolTable &MST = M.getSymbolTable();
- for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
+ TypeSymbolTable &TST = M.getTypeSymbolTable();
+ for (TypeSymbolTable::iterator TI = TST.begin(), TE = TST.end();
TI != TE; ) {
- SymbolTable::type_iterator I = TI++;
+ TypeSymbolTable::iterator I = TI++;
// If this is not used, remove it from the symbol table.
std::set<const Type *>::iterator UTI = UT.find(I->second);
if (UTI == UT.end())
- MST.remove(I);
+ TST.remove(I);
else
UT.erase(UTI); // Only keep one name for this type.
}
@@ -1421,7 +1422,7 @@ bool CWriter::doInitialization(Module &M) {
//
// Loop over the symbol table, emitting all named constants...
- printModuleTypes(M.getSymbolTable());
+ printModuleTypes(M.getTypeSymbolTable());
// Global variable declarations...
if (!M.global_empty()) {
@@ -1589,7 +1590,7 @@ void CWriter::printFloatingPointConstants(Function &F) {
/// printSymbolTable - Run through symbol table looking for type names. If a
/// type name is found, emit its declaration...
///
-void CWriter::printModuleTypes(const SymbolTable &ST) {
+void CWriter::printModuleTypes(const TypeSymbolTable &TST) {
Out << "/* Helper union for bitcasts */\n";
Out << "typedef union {\n";
Out << " unsigned int Int32;\n";
@@ -1599,8 +1600,8 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
Out << "} llvmBitCastUnion;\n";
// We are only interested in the type plane of the symbol table.
- SymbolTable::type_const_iterator I = ST.type_begin();
- SymbolTable::type_const_iterator End = ST.type_end();
+ TypeSymbolTable::const_iterator I = TST.begin();
+ TypeSymbolTable::const_iterator End = TST.end();
// If there are no type names, exit early.
if (I == End) return;
@@ -1618,7 +1619,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// Now we can print out typedefs...
Out << "/* Typedefs */\n";
- for (I = ST.type_begin(); I != End; ++I) {
+ for (I = TST.begin(); I != End; ++I) {
const Type *Ty = cast<Type>(I->second);
std::string Name = "l_" + Mang->makeNameProper(I->first);
Out << "typedef ";
@@ -1635,7 +1636,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// printed in the correct order.
//
Out << "/* Structure contents */\n";
- for (I = ST.type_begin(); I != End; ++I)
+ for (I = TST.begin(); I != End; ++I)
if (const StructType *STy = dyn_cast<StructType>(I->second))
// Only print out used types!
printContainedStructs(STy, StructPrinted);
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index 8199f746a2..871bcff158 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -16,7 +16,7 @@
#include "llvm/Transforms/IPO.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Module.h"
-#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
@@ -69,14 +69,15 @@ static inline bool ShouldNukeSymtabEntry(const Type *Ty){
bool DTE::runOnModule(Module &M) {
bool Changed = false;
- SymbolTable &ST = M.getSymbolTable();
+ TypeSymbolTable &ST = M.getTypeSymbolTable();
std::set<const Type *> UsedTypes = getAnalysis<FindUsedTypes>().getTypes();
// Check the symbol table for superfluous type entries...
//
// Grab the 'type' plane of the module symbol...
- SymbolTable::type_iterator TI = ST.type_begin();
- while ( TI != ST.type_end() ) {
+ TypeSymbolTable::iterator TI = ST.begin();
+ TypeSymbolTable::iterator TE = ST.end();
+ while ( TI != TE ) {
// If this entry should be unconditionally removed, or if we detect that
// the type is not used, remove it.
const Type *RHS = TI->second;
diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp
index 75b24a7282..12cd7fe893 100644
--- a/lib/Transforms/IPO/StripSymbols.cpp
+++ b/lib/Transforms/IPO/StripSymbols.cpp
@@ -29,6 +29,7 @@
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
using namespace llvm;
namespace {
@@ -83,13 +84,11 @@ bool StripSymbols::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (I->hasInternalLinkage())
I->setName(""); // Internal symbols can't participate in linkage
- I->getSymbolTable().strip();
+ I->getValueSymbolTable().strip();
}
// Remove all names from types.
- SymbolTable &SymTab = M.getSymbolTable();
- while (SymTab.type_begin() != SymTab.type_end())
- SymTab.remove(SymTab.type_begin());
+ M.getTypeSymbolTable().strip();
}
// Strip debug info in the module if it exists. To do this, we remove
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index 229debf198..696d9d1b05 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -16,6 +16,7 @@
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Constant.h"
#include "ValueMapper.h"
using namespace llvm;
@@ -42,11 +43,10 @@ Module *llvm::CloneModule(const Module *M, std::map<const Value*, Value*> &Value
New->setModuleInlineAsm(M->getModuleInlineAsm());
// Copy all of the type symbol table entries over.
- const SymbolTable &SymTab = M->getSymbolTable();
- SymbolTable::type_const_iterator TypeI = SymTab.type_begin();
- SymbolTable::type_const_iterator TypeE = SymTab.type_end();
- for (; TypeI != TypeE; ++TypeI)
- New->addTypeName(TypeI->first, TypeI->second);
+ const TypeSymbolTable &TST = M->getTypeSymbolTable();
+ for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
+ TI != TE; ++TI)
+ New->addTypeName(TI->first, TI->second);
// Copy all of the dependent libraries over.
for (Module::lib_iterator I = M->lib_begin(), E = M->lib_end(); I != E; ++I)
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index f5b2484429..64cac8c518 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -25,6 +25,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CFG.h"
@@ -216,9 +217,9 @@ static std::string getLLVMName(const std::string &Name,
static void fillTypeNameTable(const Module *M,
std::map<const Type *, std::string> &TypeNames) {
if (!M) return;
- const SymbolTable &ST = M->getSymbolTable();
- SymbolTable::type_const_iterator TI = ST.type_begin();
- for (; TI != ST.type_end(); ++TI) {
+ const TypeSymbolTable &ST = M->getTypeSymbolTable();
+ TypeSymbolTable::const_iterator TI = ST.begin();
+ for (; TI != ST.end(); ++TI) {
// As a heuristic, don't insert pointer to primitive types, because
// they are used too often to have a single useful name.
//
@@ -666,7 +667,8 @@ public:
private:
void printModule(const Module *M);
- void printSymbolTable(const SymbolTable &ST);
+ void printTypeSymbolTable(const TypeSymbolTable &ST);
+ void printValueSymbolTable(const SymbolTable &ST);
void printConstant(const Constant *CPV);
void printGlobal(const GlobalVariable *GV);
void printFunction(const Function *F);
@@ -818,7 +820,8 @@ void AssemblyWriter::printModule(const Module *M) {
}
// Loop over the symbol table, emitting all named constants.
- printSymbolTable(M->getSymbolTable());
+ printTypeSymbolTable(M->getTypeSymbolTable());
+ printValueSymbolTable(M->getValueSymbolTable());
for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
@@ -873,14 +876,10 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
Out << "\n";
}
-
-// printSymbolTable - Run through symbol table looking for constants
-// and types. Emit their declarations.
-void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
-
+void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) {
// Print the types.
- for (SymbolTable::type_const_iterator TI = ST.type_begin();
- TI != ST.type_end(); ++TI) {
+ for (TypeSymbolTable::const_iterator TI = ST.begin(), TE = ST.end();
+ TI != TE; ++TI) {
Out << "\t" << getLLVMName(TI->first) << " = type ";
// Make sure we print out at least one level of the type structure, so
@@ -888,6 +887,11 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
//
printTypeAtLeastOneLevel(TI->second) << "\n";
}
+}
+
+// printSymbolTable - Run through symbol table looking for constants
+// and types. Emit their declarations.
+void AssemblyWriter::printValueSymbolTable(const SymbolTable &ST) {
// Print the constants, in type plane order.
for (SymbolTable::plane_const_iterator PI = ST.plane_begin();
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index e8bbd86590..4bc93dbb2c 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -144,8 +144,8 @@ void Function::eraseFromParent() {
/// required before printing out to a textual form, to ensure that there is no
/// ambiguity when parsing.
void Function::renameLocalSymbols() {
- SymbolTable &LST = getSymbolTable(); // Local Symtab
- SymbolTable &GST = getParent()->getSymbolTable(); // Global Symtab
+ SymbolTable &LST = getValueSymbolTable(); // Local Symtab
+ SymbolTable &GST = getParent()->getValueSymbolTable(); // Global Symtab
for (SymbolTable::plane_iterator LPI = LST.plane_begin(), E = LST.plane_end();
LPI != E; ++LPI)
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index 6897a4f92d..98faff1d33 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
+#include "llvm/TypeSymbolTable.h"
#include <algorithm>
#include <cstdarg>
#include <cstdlib>
@@ -68,7 +69,8 @@ Module::Module(const std::string &MID)
FunctionList.setParent(this);
GlobalList.setItemParent(this);
GlobalList.setParent(this);
- SymTab = new SymbolTable();
+ ValSymTab = new SymbolTable();
+ TypeSymTab = new TypeSymbolTable();
}
Module::~Module() {
@@ -78,7 +80,8 @@ Module::~Module() {
FunctionList.clear();
FunctionList.setParent(0);
LibraryList.clear();
- delete SymTab;
+ delete ValSymTab;
+ delete TypeSymTab;
}
// Module::dump() - Allow printing from debugger
@@ -156,7 +159,7 @@ void Module::setPointerSize(PointerSize PS) {
//
Function *Module::getOrInsertFunction(const std::string &Name,
const FunctionType *Ty) {
- SymbolTable &SymTab = getSymbolTable();
+ SymbolTable &SymTab = getValueSymbolTable();
// See if we have a definitions for the specified function already...
if (Value *V = SymTab.lookup(PointerType::get(Ty), Name)) {
@@ -194,7 +197,7 @@ Function *Module::getOrInsertFunction(const std::string &Name,
// If it does not exist, return null.
//
Function *Module::getFunction(const std::string &Name, const FunctionType *Ty) {
- SymbolTable &SymTab = getSymbolTable();
+ SymbolTable &SymTab = getValueSymbolTable();
return cast_or_null<Function>(SymTab.lookup(PointerType::get(Ty), Name));
}
@@ -275,7 +278,7 @@ Function *Module::getNamedFunction(const std::string &Name) const {
///
GlobalVariable *Module::getGlobalVariable(const std::string &Name,
const Type *Ty, bool AllowInternal) {
- if (Value *V = getSymbolTable().lookup(PointerType::get(Ty), Name)) {
+ if (Value *V = getValueSymbolTable().lookup(PointerType::get(Ty), Name)) {
GlobalVariable *Result = cast<GlobalVariable>(V);
if (AllowInternal || !Result->hasInternalLinkage())
return Result;
@@ -309,9 +312,9 @@ GlobalVariable *Module::getNamedGlobal(const std::string &Name) const {
// table is not modified.
//
bool Module::addTypeName(const std::string &Name, const Type *Ty) {
- SymbolTable &ST = getSymbolTable();
+ TypeSymbolTable &ST = getTypeSymbolTable();
- if (ST.lookupType(Name)) return true; // Already in symtab...
+ if (ST.lookup(Name)) return true; // Already in symtab...
// Not in symbol table? Set the name with the Symtab as an argument so the
// type knows what to update...
@@ -323,18 +326,18 @@ bool Module::addTypeName(const std::string &Name, const Type *Ty) {
/// getTypeByName - Return the type with the specified name in this module, or
/// null if there is none by that name.
const Type *Module::getTypeByName(const std::string &Name) const {
- const SymbolTable &ST = getSymbolTable();
- return cast_or_null<Type>(ST.lookupType(Name));
+ const TypeSymbolTable &ST = getTypeSymbolTable();
+ return cast_or_null<Type>(ST.lookup(Name));
}
// getTypeName - If there is at least one entry in the symbol table for the
// specified type, return it.
//
std::string Module::getTypeName(const Type *Ty) const {
- const SymbolTable &ST = getSymbolTable();
+ const TypeSymbolTable &ST = getTypeSymbolTable();
- SymbolTable::type_const_iterator TI = ST.type_begin();
- SymbolTable::type_const_iterator TE = ST.type_end();
+ TypeSymbolTable::const_iterator TI = ST.begin();
+ TypeSymbolTable::const_iterator TE = ST.end();
if ( TI == TE ) return ""; // No names for types
while (TI != TE && TI->second != Ty)
diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp
index 7ea3377ab9..c20366cf35 100644
--- a/lib/VMCore/SymbolTable.cpp
+++ b/lib/VMCore/SymbolTable.cpp
@@ -24,12 +24,6 @@ using namespace llvm;
#define DEBUG_ABSTYPE 0
SymbolTable::~SymbolTable() {
- // Drop all abstract type references in the type plane...
- for (type_iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
- if (TI->second->isAbstract()) // If abstract, drop the reference...
- cast<DerivedType>(TI->second)->removeAbstractTypeUser(this);
- }
-
// TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the
// planes that could still have entries!
@@ -82,14 +76,6 @@ Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) const {
}
-// lookup a type by name - returns null on failure
-Type* SymbolTable::lookupType(const std::string& Name) const {
- type_const_iterator TI = tmap.find(Name);
- if (TI != tmap.end())
- return const_cast<Type*>(TI->second);
- return 0;
-}
-
/// changeName - Given a value with a non-empty name, remove its existing entry
/// from the symbol table and insert a new one for Name. This is equivalent to
/// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not
@@ -158,32 +144,6 @@ void SymbolTable::remove(Value *N) {
}
}
-// remove - Remove a type from the symbol table...
-Type* SymbolTable::remove(type_iterator Entry) {
- assert(Entry != tmap.end() && "Invalid entry to remove!");
-
- const Type* Result = Entry->second;
-
-#if DEBUG_SYMBOL_TABLE
- dump();
- DOUT << " Removing type: " << Entry->first << "\n";
-#endif
-
- tmap.erase(Entry);
-
- // If we are removing an abstract type, remove the symbol table from it's use
- // list...
- if (Result->isAbstract()) {
-#if DEBUG_ABSTYPE
- DOUT << "Removing abstract type from symtab"
- << Result->getDescription() << "\n";
-#endif
- cast<DerivedType>(Result)->removeAbstractTypeUser(this);
- }
-
- return const_cast<Type*>(Result);
-}
-
// insertEntry - Insert a value into the symbol table with the specified name.
void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
@@ -230,34 +190,6 @@ void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
}
-// insertEntry - Insert a type into the symbol table with the specified
-// name...
-//
-void SymbolTable::insert(const std::string& Name, const Type* T) {
- assert(T && "Can't insert null type into symbol table!");
-
- // Check to see if there is a naming conflict. If so, rename this type!
- std::string UniqueName = Name;
- if (lookupType(Name))
- UniqueName = getUniqueName(T, Name);
-
-#if DEBUG_SYMBOL_TABLE
- dump();
- DOUT << " Inserting type: " << UniqueName << ": "
- << T->getDescription() << "\n";
-#endif
-
- // Insert the tmap entry
- tmap.insert(make_pair(UniqueName, T));
-
- // If we are adding an abstract type, add the symbol table to it's use list.
- if (T->isAbstract()) {
- cast<DerivedType>(T)->addAbstractTypeUser(this);
-#if DEBUG_ABSTYPE
- DOUT << "Added abstract type to ST: " << T->getDescription() << "\n";
-#endif
- }
-}
// Strip the symbol table of its names.
bool SymbolTable::strip() {
@@ -278,11 +210,6 @@ bool SymbolTable::strip() {
}
}
- for (type_iterator TI = tmap.begin(); TI != tmap.end(); ) {
- remove(TI++);
- RemovedSymbol = true;
- }
-
return RemovedSymbol;
}
@@ -375,28 +302,6 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
// Remove the plane that is no longer used
pmap.erase(PI);
}
-
- // Loop over all of the types in the symbol table, replacing any references
- // to OldType with references to NewType. Note that there may be multiple
- // occurrences, and although we only need to remove one at a time, it's
- // faster to remove them all in one pass.
- //
- for (type_iterator I = type_begin(), E = type_end(); I != E; ++I) {
- if (I->second == (Type*)OldType) { // FIXME when Types aren't const.
-#if DEBUG_ABSTYPE
- DOUT << "Removing type " << OldType->getDescription() << "\n";
-#endif
- OldType->removeAbstractTypeUser(this);
-
- I->second = (Type*)NewType; // TODO FIXME when types aren't const
- if (NewType->isAbstract()) {
-#if DEBUG_ABSTYPE
- DOUT << "Added type " << NewType->getDescription() << "\n";
-#endif
- cast<DerivedType>(NewType)->addAbstractTypeUser(this);
- }
- }
- }
}
@@ -408,13 +313,6 @@ void SymbolTable::typeBecameConcrete(const DerivedType *AbsTy) {
// plane is a use of the abstract type which must be dropped.
if (PI != pmap.end())
AbsTy->removeAbstractTypeUser(this);
-
- // Loop over all of the types in the symbol table, dropping any abstract
- // type user entries for AbsTy which occur because there are names for the
- // type.
- for (type_iterator TI = type_begin(), TE = type_end(); TI != TE; ++TI)
- if (TI->second == (Type*)AbsTy) // FIXME when Types aren't const.
- AbsTy->removeAbstractTypeUser(this);
}
static void DumpVal(const std::pair<const std::string, Value *> &V) {
@@ -430,17 +328,9 @@ static void DumpPlane(const std::pair<const Type *,
for_each(P.second.begin(), P.second.end(), DumpVal);
}
-static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
- DOUT << " '" << T.first << "' = ";
- T.second->dump();
- DOUT << "\n";
-}
-
void SymbolTable::dump() const {
DOUT << "Symbol table dump:\n Plane:";
for_each(pmap.begin(), pmap.end(), DumpPlane);
- DOUT << " Types: ";
- for_each(tmap.begin(), tmap.end(), DumpTypes);
}
// vim: sw=2 ai
diff --git a/lib/VMCore/SymbolTableListTraitsImpl.h b/lib/VMCore/SymbolTableListTraitsImpl.h
index 6d70401c89..81849dd031 100644
--- a/lib/VMCore/SymbolTableListTraitsImpl.h
+++ b/lib/VMCore/SymbolTableListTraitsImpl.h
@@ -29,7 +29,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
// Remove all of the items from the old symtab..
if (SymTabObject && !List.empty()) {
- SymbolTable &SymTab = SymTabObject->getSymbolTable();
+ SymbolTable &SymTab = SymTabObject->getValueSymbolTable();
for (typename iplist<ValueSubClass>::iterator I = List.begin();
I != List.end(); ++I)
if (I->hasName()) SymTab.remove(I);
@@ -39,7 +39,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
// Add all of the items to the new symtab...
if (SymTabObject && !List.empty()) {
- SymbolTable &SymTab = SymTabObject->getSymbolTable();
+ SymbolTable &SymTab = SymTabObject->getValueSymbolTable();
for (typename iplist<ValueSubClass>::iterator I = List.begin();
I != List.end(); ++I)
if (I->hasName()) SymTab.insert(I);
@@ -53,7 +53,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
assert(V->getParent() == 0 && "Value already in a container!!");
V->setParent(ItemParent);
if (V->hasName() && SymTabObject)
- SymTabObject->getSymbolTable().insert(V);
+ SymTabObject->getValueSymbolTable().insert(V);
}
template<typename ValueSubClass, typename ItemParentClass, typename SymTabClass,
@@ -62,7 +62,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
::removeNodeFromList(ValueSubClass *V) {
V->setParent(0);
if (V->hasName() && SymTabObject)
- SymTabObject->getSymbolTable().remove(V);
+ SymTabObject->getValueSymbolTable().remove(V);
}
template<typename ValueSubClass, typename ItemParentClass, typename SymTabClass,
@@ -83,10 +83,10 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
ValueSubClass &V = *first;
bool HasName = V.hasName();
if (OldSTO && HasName)
- OldSTO->getSymbolTable().remove(&V);
+ OldSTO->getValueSymbolTable().remove(&V);
V.setParent(NewIP);
if (NewSTO && HasName)
- NewSTO->getSymbolTable().insert(&V);
+ NewSTO->getValueSymbolTable().insert(&V);
}
} else {
// Just transferring between blocks in the same function, simply update the
diff --git a/lib/VMCore/TypeSymbolTable.cpp b/lib/VMCore/TypeSymbolTable.cpp
index cfd8cbf935..ac89bb6645 100644
--- a/lib/VMCore/TypeSymbolTable.cpp
+++ b/lib/VMCore/TypeSymbolTable.cpp
@@ -48,10 +48,10 @@ Type* TypeSymbolTable::lookup(const std::string& Name) const {
}
// Erase a specific type from the symbol table
-bool TypeSymbolTable::erase(Type *N) {
+bool TypeSymbolTable::remove(Type *N) {
for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
if (TI->second == N) {
- this->erase(TI);
+ this->remove(TI);
return true;
}
}
@@ -59,7 +59,7 @@ bool TypeSymbolTable::erase(Type *N) {
}
// remove - Remove a type from the symbol table...
-Type* TypeSymbolTable::erase(iterator Entry) {
+Type* TypeSymbolTable::remove(iterator Entry) {
assert(Entry != tmap.end() && "Invalid entry to remove!");
const Type* Result = Entry->second;
@@ -115,7 +115,7 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
bool TypeSymbolTable::strip() {
bool RemovedSymbol = false;
for (iterator TI = tmap.begin(); TI != tmap.end(); ) {
- erase(TI++);
+ remove(TI++);
RemovedSymbol = true;
}
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index 0d9dc07fa0..94c03b834a 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -101,13 +101,13 @@ void Value::setName(const std::string &name) {
if (Instruction *I = dyn_cast<Instruction>(this)) {
if (BasicBlock *P = I->getParent())
if (Function *PP = P->getParent())
- ST = &PP->getSymbolTable();
+ ST = &PP->getValueSymbolTable();
} else if (BasicBlock *BB = dyn_cast<BasicBlock>(this)) {
- if (Function *P = BB->getParent()) ST = &P->getSymbolTable();
+ if (Function *P = BB->getParent()) ST = &P->getValueSymbolTable();
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(this)) {
- if (Module *P = GV->getParent()) ST = &P->getSymbolTable();
+ if (Module *P = GV->getParent()) ST = &P->getValueSymbolTable();
} else if (Argument *A = dyn_cast<Argument>(this)) {
- if (Function *P = A->getParent()) ST = &P->getSymbolTable();
+ if (Function *P = A->getParent()) ST = &P->getValueSymbolTable();
} else {
assert(isa<Constant>(this) && "Unknown value type!");
return; // no name is setable for this.
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 719c6f2f5f..e03bb6d1d9 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -99,7 +99,8 @@ namespace { // Anonymous namespace for class
bool doInitialization(Module &M) {
Mod = &M;
- verifySymbolTable(M.getSymbolTable());
+ verifyTypeSymbolTable(M.getTypeSymbolTable());
+ verifyValueSymbolTable(M.getValueSymbolTable());
// If this is a real pass, in a pass manager, we must abort before
// returning back to the pass manager, or else the pass manager may try to
@@ -173,7 +174,8 @@ namespace { // Anonymous namespace for class
// Verification methods...
- void verifySymbolTable(SymbolTable &ST);
+ void verifyTypeSymbolTable(TypeSymbolTable &ST);
+ void verifyValueSymbolTable(SymbolTable &ST);
void visitGlobalValue(GlobalValue &GV);
void visitGlobalVariable(GlobalVariable &GV);
void visitFunction(Function &F);
@@ -301,10 +303,12 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
visitGlobalValue(GV);
}
+void Verifier::verifyTypeSymbolTable(TypeSymbolTable &ST) {
+}
// verifySymbolTable - Verify that a function or module symbol table is ok
//
-void Verifier::verifySymbolTable(SymbolTable &ST) {
+void Verifier::verifyValueSymbolTable(SymbolTable &ST) {
// Loop over all of the values in all type planes in the symbol table.
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
@@ -372,7 +376,7 @@ void Verifier::visitFunction(Function &F) {
Assert1(F.getName().substr(0, 5) != "llvm.",
"llvm intrinsics cannot be defined!", &F);
- verifySymbolTable(F.getSymbolTable());
+ verifyValueSymbolTable(F.getValueSymbolTable());
// Check the entry node
BasicBlock *Entry = &F.getEntryBlock();
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 73b49be212..23aad53adf 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -337,7 +337,7 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// module, and that they don't include any deleted blocks.
BBs.clear();
for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
- SymbolTable &ST = BlockInfo[i].first->getSymbolTable();
+ SymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
SymbolTable::plane_iterator PI = ST.find(Type::LabelTy);
if (PI != ST.plane_end() && PI->second.count(BlockInfo[i].second))
BBs.push_back(cast<BasicBlock>(PI->second[BlockInfo[i].second]));
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index d2d2d849f5..b0eb1209e7 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -20,6 +20,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
@@ -189,10 +190,10 @@ getTypePrefix(const Type* Ty ) {
// Mode::getTypeName function which will return an empty string, not a null
// pointer if the name is not found.
inline const std::string*
-findTypeName(const SymbolTable& ST, const Type* Ty)
+findTypeName(const TypeSymbolTable& ST, const Type* Ty)
{
- SymbolTable::type_const_iterator TI = ST.type_begin();
- SymbolTable::type_const_iterator TE = ST.type_end();
+ TypeSymbolTable::const_iterator TI = ST.begin();
+ TypeSymbolTable::const_iterator TE = ST.end();
for (;TI != TE; ++TI)
if (TI->second == Ty)
return &(TI->first);
@@ -348,7 +349,7 @@ CppWriter::getCppName(const Type* Ty)
}
// See if the type has a name in the symboltable and build accordingly
- const std::string* tName = findTypeName(TheModule->getSymbolTable(), Ty);
+ const std::string* tName = findTypeName(TheModule->getTypeSymbolTable(), Ty);
std::string name;
if (tName)
name = std::string(prefix) + *tName;
@@ -539,7 +540,7 @@ CppWriter::printTypeInternal(const Type* Ty) {
// If the type had a name, make sure we recreate it.
const std::string* progTypeName =
- findTypeName(TheModule->getSymbolTable(),Ty);
+ findTypeName(TheModule->getTypeSymbolTable(),Ty);
if (progTypeName)
Out << "mod->addTypeName(\"" << *progTypeName << "\", "
<< typeName << ");";
@@ -596,9 +597,9 @@ void
CppWriter::printTypes(const Module* M) {
// Walk the symbol table and print out all its types
- const SymbolTable& symtab = M->getSymbolTable();
- for (SymbolTable::type_const_iterator TI = symtab.type_begin(),
- TE = symtab.type_end(); TI != TE; ++TI) {
+ const TypeSymbolTable& symtab = M->getTypeSymbolTable();
+ for (TypeSymbolTable::const_iterator TI = symtab.begin(), TE = symtab.end();
+ TI != TE; ++TI) {
// For primitive types and types already defined, just add a name
TypeMap::const_iterator TNI = TypeNames.find(TI->second);