- 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
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index a1860a9..2ea9ac2 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -63,35 +63,34 @@
 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 cbcfa2a..bb3a9af 100644
--- a/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/lib/Transforms/IPO/FunctionResolution.cpp
@@ -304,8 +304,7 @@
 }
 
 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 @@
   // 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 84f5785..9520823 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -209,7 +209,7 @@
       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 5f52969..99e596e 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 22377ba..3383427 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -28,7 +28,7 @@
 
   // 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 8fe9113..0d3cc9b 100644
--- a/lib/Transforms/Utils/Linker.cpp
+++ b/lib/Transforms/Utils/Linker.cpp
@@ -32,11 +32,8 @@
 // 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 @@
                         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 @@
                                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