From: Chris Lattner Date: Tue, 15 Oct 2002 21:26:29 +0000 (+0000) Subject: - Eliminate SymbolTable::ParentSymTab, ST::localLookup, and X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0dad6e9c95984804953db0fdcbe0c907d9ee351e;p=oota-llvm.git - Eliminate SymbolTable::ParentSymTab, ST::localLookup, and Function::ParentSymTab. These aren't needed at all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4186 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 87e6bad48a3..bb2c3ca9967 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -57,7 +57,7 @@ private: BasicBlockListType BasicBlocks; // The basic blocks ArgumentListType ArgumentList; // The formal arguments - SymbolTable *SymTab, *ParentSymTab; + SymbolTable *SymTab; friend class SymbolTableListTraits; diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index 8762b4b5819..7e7cb51f20a 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -25,33 +25,16 @@ class SymbolTable : public AbstractTypeUser, public: typedef std::map VarMap; typedef std::map super; -private: - - SymbolTable *ParentSymTab; - friend class Function; - inline void setParentSymTab(SymbolTable *P) { ParentSymTab = P; } - -public: typedef VarMap::iterator type_iterator; typedef VarMap::const_iterator type_const_iterator; - inline SymbolTable(SymbolTable *P = 0) { - ParentSymTab = P; - InternallyInconsistent = false; - } + inline SymbolTable() : InternallyInconsistent(false) {} ~SymbolTable(); - SymbolTable *getParentSymTab() { return ParentSymTab; } - // lookup - Returns null on failure... Value *lookup(const Type *Ty, const std::string &name); - // localLookup - Look in this symbol table without falling back on parent, - // if non-existing. Returns null on failure... - // - Value *localLookup(const Type *Ty, const std::string &name); - // insert - Add named definition to the symbol table... inline void insert(Value *N) { assert(N->hasName() && "Value must be named to go into symbol table!"); diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index d03a72a81ab..5edd9ae2a69 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -84,7 +84,7 @@ Function::Function(const FunctionType *Ty, bool isInternal, BasicBlocks.setParent(this); ArgumentList.setItemParent(this); ArgumentList.setParent(this); - ParentSymTab = SymTab = 0; + SymTab = 0; // Create the arguments vector, all arguments start out unnamed. for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) { @@ -127,10 +127,6 @@ void Function::setParent(Module *parent) { Parent = parent; if (getParent()) LeakDetector::removeGarbageObject(this); - - // Relink symbol tables together... - ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0; - if (SymTab) SymTab->setParentSymTab(ParentSymTab); } const FunctionType *Function::getFunctionType() const { @@ -142,7 +138,7 @@ const Type *Function::getReturnType() const { } SymbolTable *Function::getSymbolTableSure() { - if (!SymTab) SymTab = new SymbolTable(ParentSymTab); + if (!SymTab) SymTab = new SymbolTable(); return SymTab; } diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 4bd3a884b30..397b5e28341 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -75,7 +75,7 @@ void Module::dump() const { } SymbolTable *Module::getSymbolTableSure() { - if (!SymTab) SymTab = new SymbolTable(0); + if (!SymTab) SymTab = new SymbolTable(); return SymTab; } diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index 6d09c7d5669..069f7111019 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -72,7 +72,7 @@ string SymbolTable::getUniqueName(const Type *Ty, const string &BaseName) { // lookup - Returns null on failure... -Value *SymbolTable::localLookup(const Type *Ty, const string &Name) { +Value *SymbolTable::lookup(const Type *Ty, const string &Name) { iterator I = find(Ty); if (I != end()) { // We have symbols in that plane... type_iterator J = I->second.find(Name); @@ -83,13 +83,6 @@ Value *SymbolTable::localLookup(const Type *Ty, const string &Name) { return 0; } -// lookup - Returns null on failure... -Value *SymbolTable::lookup(const Type *Ty, const string &Name) { - Value *LV = localLookup(Ty, Name); - if (LV) return LV; - return ParentSymTab ? ParentSymTab->lookup(Ty, Name) : 0; -} - void SymbolTable::remove(Value *N) { assert(N->hasName() && "Value doesn't have name!"); if (InternallyInconsistent) return; @@ -154,7 +147,7 @@ Value *SymbolTable::removeEntry(iterator Plane, type_iterator Entry) { void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) { // Check to see if there is a naming conflict. If so, rename this value! - if (localLookup(VTy, Name)) { + if (lookup(VTy, Name)) { string UniqueName = getUniqueName(VTy, Name); assert(InternallyInconsistent == false && "Infinite loop inserting entry!"); InternallyInconsistent = true; @@ -339,9 +332,4 @@ static void DumpPlane(const pair >&P) { void SymbolTable::dump() const { std::cout << "Symbol table dump:\n"; for_each(begin(), end(), DumpPlane); - - if (ParentSymTab) { - std::cout << "Parent "; - ParentSymTab->dump(); - } }