diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-05-25 08:53:40 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-05-25 08:53:40 +0000 |
commit | 9231ac8b6f2c3f9877bdb7a223f7392061258ab6 (patch) | |
tree | 9f97206d6e486301c3bfb513b1872e5b1d4f5b20 /lib/Transforms/IPO | |
parent | af90b0d8b8071b4ddc9e5932abde7a1845defdba (diff) | |
download | external_llvm-9231ac8b6f2c3f9877bdb7a223f7392061258ab6.zip external_llvm-9231ac8b6f2c3f9877bdb7a223f7392061258ab6.tar.gz external_llvm-9231ac8b6f2c3f9877bdb7a223f7392061258ab6.tar.bz2 |
Convert to SymbolTable's new iteration interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 33 | ||||
-rw-r--r-- | lib/Transforms/IPO/MutateStructTypes.cpp | 18 |
2 files changed, 24 insertions, 27 deletions
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index c3a9f6e..28e5dca 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/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/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index ad18bae..38f9445 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/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 |