diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-20 18:36:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-20 18:36:02 +0000 |
commit | 6e6026b46569b01f8f6d4dcdb6c899c3a9c76b3e (patch) | |
tree | 57322a305c9e9d3273ae9d3d09728ec2662e97d8 /lib/Transforms | |
parent | c09aab0a4de7e3f65dd830803faadb7abae28872 (diff) | |
download | external_llvm-6e6026b46569b01f8f6d4dcdb6c899c3a9c76b3e.tar.gz external_llvm-6e6026b46569b01f8f6d4dcdb6c899c3a9c76b3e.tar.bz2 external_llvm-6e6026b46569b01f8f6d4dcdb6c899c3a9c76b3e.zip |
- Eliminated the deferred symbol table stuff in Module & Function, it really
wasn't an optimization and it was causing lots of bugs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 49 | ||||
-rw-r--r-- | lib/Transforms/IPO/FunctionResolution.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/LevelRaise.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SymbolStripping.cpp | 9 | ||||
-rw-r--r-- | lib/Transforms/Utils/BasicBlockUtils.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/Linker.cpp | 11 |
6 files changed, 36 insertions, 42 deletions
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index a1860a92e9..2ea9ac2a56 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -63,35 +63,34 @@ static inline bool ShouldNukeSymtabEntry(const std::pair<std::string,Value*>&E){ bool DTE::run(Module &M) { bool Changed = false; - if (SymbolTable *ST = M.getSymbolTable()) { - const std::set<const Type *> &UsedTypes = - getAnalysis<FindUsedTypes>().getTypes(); + SymbolTable &ST = M.getSymbolTable(); + const 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::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. - // - if (ShouldNukeSymtabEntry(*PI) || - !UsedTypes.count(cast<Type>(PI->second))) { + // 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. + // + if (ShouldNukeSymtabEntry(*PI) || + !UsedTypes.count(cast<Type>(PI->second))) { #if MAP_IS_NOT_BRAINDEAD - PI = Plane.erase(PI); // STD C++ Map should support this! + PI = Plane.erase(PI); // STD C++ Map should support this! #else - Plane.erase(PI); // Alas, GCC 2.95.3 doesn't *SIGH* - PI = Plane.begin(); + Plane.erase(PI); // Alas, GCC 2.95.3 doesn't *SIGH* + PI = Plane.begin(); #endif - ++NumKilled; - Changed = true; - } else { - ++PI; - } - } + ++NumKilled; + Changed = true; + } else { + ++PI; + } } return Changed; diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index cbcfa2aba8..bb3a9af659 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -304,8 +304,7 @@ static bool ProcessGlobalsWithSameName(Module &M, } bool FunctionResolvingPass::run(Module &M) { - SymbolTable *ST = M.getSymbolTable(); - if (!ST) return false; + SymbolTable &ST = M.getSymbolTable(); std::map<string, vector<GlobalValue*> > Globals; @@ -313,7 +312,7 @@ bool FunctionResolvingPass::run(Module &M) { // then add it to the Functions map. We do a two pass algorithm here to avoid // problems with iterators getting invalidated if we did a one pass scheme. // - for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I) + for (SymbolTable::iterator I = ST.begin(), E = ST.end(); I != E; ++I) if (const PointerType *PT = dyn_cast<PointerType>(I->first)) { SymbolTable::VarMap &Plane = I->second; for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end(); diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index 84f57852cd..9520823206 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -209,7 +209,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { if (!Src->hasName() && CI->hasName()) { std::string Name = CI->getName(); CI->setName(""); - Src->setName(Name, BB->getParent()->getSymbolTable()); + Src->setName(Name, &BB->getParent()->getSymbolTable()); } // DCE the instruction now, to avoid having the iterative version of DCE diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 5f52969075..99e596e8f2 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -19,20 +19,19 @@ #include "llvm/SymbolTable.h" #include "llvm/Pass.h" -static bool StripSymbolTable(SymbolTable *SymTab) { - if (SymTab == 0) return false; // No symbol table? No problem. +static bool StripSymbolTable(SymbolTable &SymTab) { bool RemovedSymbol = false; - for (SymbolTable::iterator I = SymTab->begin(); I != SymTab->end(); ++I) { + for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end(); ++I) { std::map<const std::string, Value *> &Plane = I->second; SymbolTable::type_iterator B; while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane! Value *V = B->second; if (isa<Constant>(V) || isa<Type>(V)) - SymTab->type_remove(B); + SymTab.type_remove(B); else - V->setName("", SymTab); // Set name to "", removing from symbol table! + V->setName("", &SymTab); // Set name to "", removing from symbol table! RemovedSymbol = true; assert(Plane.begin() != B && "Symbol not removed from table!"); } diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index 22377ba3ed..33834277b7 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -28,7 +28,7 @@ void ReplaceInstWithValue(BasicBlock::InstListType &BIL, // Make sure to propagate a name if there is one already... if (OldName.size() && !V->hasName()) - V->setName(OldName, BIL.getParent()->getSymbolTable()); + V->setName(OldName, &BIL.getParent()->getSymbolTable()); } diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index 8fe9113d82..0d3cc9bfa9 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -32,11 +32,8 @@ static inline bool Error(string *E, string Message) { // Make sure there are no type name conflicts. // static bool LinkTypes(Module *Dest, const Module *Src, string *Err = 0) { - // No symbol table? Can't have named types. - if (!Src->hasSymbolTable()) return false; - - SymbolTable *DestST = Dest->getSymbolTableSure(); - const SymbolTable *SrcST = Src->getSymbolTable(); + SymbolTable *DestST = &Dest->getSymbolTable(); + const SymbolTable *SrcST = &Src->getSymbolTable(); // Look for a type plane for Type's... SymbolTable::const_iterator PI = SrcST->find(Type::TypeTy); @@ -176,7 +173,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, map<const Value*, Value*> &ValueMap, string *Err = 0) { // We will need a module level symbol table if the src module has a module // level symbol table... - SymbolTable *ST = Src->getSymbolTable() ? Dest->getSymbolTableSure() : 0; + SymbolTable *ST = (SymbolTable*)&Src->getSymbolTable(); // Loop over all of the globals in the src module, mapping them over as we go // @@ -266,7 +263,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, string *Err = 0) { // We will need a module level symbol table if the src module has a module // level symbol table... - SymbolTable *ST = Src->getSymbolTable() ? Dest->getSymbolTableSure() : 0; + SymbolTable *ST = (SymbolTable*)&Src->getSymbolTable(); // Loop over all of the functions in the src module, mapping them over as we // go |