diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/DeadTypeElimination.cpp | 33 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/MutateStructTypes.cpp | 18 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 12 |
3 files changed, 31 insertions, 32 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp b/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp index c3a9f6edc5b..28e5dca9f0b 100644 --- a/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -74,25 +74,24 @@ bool DTE::run(Module &M) { // Check the symbol table for superfluous type entries... // // Grab the 'type' plane of the module symbol... - SymbolTable::iterator STI = ST.find(Type::TypeTy); - if (STI != ST.end()) { - // Loop over all entries in the type plane... - SymbolTable::VarMap &Plane = STI->second; - for (SymbolTable::VarMap::iterator PI = Plane.begin(); PI != Plane.end();) { - // If this entry should be unconditionally removed, or if we detect that - // the type is not used, remove it. - const Type *RHS = cast<Type>(PI->second); - if (ShouldNukeSymtabEntry(RHS) || !UsedTypes.count(RHS)) { - Plane.erase(PI++); - ++NumKilled; - Changed = true; - } else { - ++PI; - // We only need to leave one name for each type. - UsedTypes.erase(RHS); - } + SymbolTable::type_iterator TI = ST.type_begin(); + while ( TI != ST.type_end() ) { + // If this entry should be unconditionally removed, or if we detect that + // the type is not used, remove it. + const Type *RHS = TI->second; + if (ShouldNukeSymtabEntry(RHS) || !UsedTypes.count(RHS)) { + SymbolTable::type_iterator ToRemove = TI++; + ST.remove(TI->second); + ++NumKilled; + Changed = true; + } else { + ++TI; + // We only need to leave one name for each type. + UsedTypes.erase(RHS); } } return Changed; } + +// vim: sw=2 diff --git a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp index ad18bae42a5..38f9445218c 100644 --- a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp @@ -269,16 +269,13 @@ void MutateStructTypes::processGlobals(Module &M) { // Remap the symbol table to refer to the types in a nice way // SymbolTable &ST = M.getSymbolTable(); - SymbolTable::iterator I = ST.find(Type::TypeTy); - if (I != ST.end()) { // Get the type plane for Type's - SymbolTable::VarMap &Plane = I->second; - for (SymbolTable::type_iterator TI = Plane.begin(), TE = Plane.end(); - TI != TE; ++TI) { - // FIXME: This is gross, I'm reaching right into a symbol table and - // mucking around with it's internals... but oh well. - // - TI->second = (Value*)cast<Type>(ConvertType(cast<Type>(TI->second))); - } + SymbolTable::type_iterator TI = ST.type_begin(); + SymbolTable::type_iterator TE = ST.type_end(); + for ( ; TI != TE; ++TI ) { + // FIXME: This is gross, I'm reaching right into a symbol table and + // mucking around with it's internals... but oh well. + // + TI->second = const_cast<Type*>(ConvertType(TI->second)); } } @@ -495,3 +492,4 @@ bool MutateStructTypes::run(Module &M) { return true; } +// vim: sw=2 diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index f8ee99b3069..d98848aa7c2 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/lib/Transforms/Utils/CloneModule.cpp @@ -33,11 +33,11 @@ Module *llvm::CloneModule(const Module *M) { // Copy all of the type symbol table entries over... const SymbolTable &SymTab = M->getSymbolTable(); - SymbolTable::const_iterator TypeI = SymTab.find(Type::TypeTy); - if (TypeI != SymTab.end()) - for (SymbolTable::VarMap::const_iterator I = TypeI->second.begin(), - E = TypeI->second.end(); I != E; ++I) - New->addTypeName(I->first, cast<Type>(I->second)); + 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); + } // Create the value map that maps things from the old module over to the new // module. @@ -89,3 +89,5 @@ Module *llvm::CloneModule(const Module *M) { return New; } + +// vim: sw=2 |