aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
24 files changed, 214 insertions, 275 deletions
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();