For PR411:
This patch replaces the SymbolTable class with ValueSymbolTable which does
not support types planes. This means that all symbol names in LLVM must now
be unique. The patch addresses the necessary changes to deal with this and
removes code no longer needed as a result. This completes the bulk of the
changes for this PR. Some cleanup patches will follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33918 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 66b6511..b597d82 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -20,7 +20,7 @@
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/PassManager.h"
-#include "llvm/SymbolTable.h"
+#include "llvm/ValueSymbolTable.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Support/CFG.h"
@@ -206,9 +206,9 @@
     // FIXME: bugpoint should add names to all stripped symbols.
     assert(!Funcs[i]->getName().empty() &&
            "Bugpoint doesn't work on stripped modules yet PR718!");
-    Function *CMF = M->getFunction(Funcs[i]->getName(),
-                                   Funcs[i]->getFunctionType());
+    Function *CMF = M->getFunction(Funcs[i]->getName());
     assert(CMF && "Function not in module?!");
+    assert(CMF->getFunctionType() == Funcs[i]->getFunctionType() && "wrong ty");
     Functions.insert(CMF);
   }
 
@@ -271,8 +271,9 @@
   for (unsigned i = 0, e = BBs.size(); i != e; ++i) {
     // Convert the basic block from the original module to the new module...
     const Function *F = BBs[i]->getParent();
-    Function *CMF = M->getFunction(F->getName(), F->getFunctionType());
+    Function *CMF = M->getFunction(F->getName());
     assert(CMF && "Function not in module?!");
+    assert(CMF->getFunctionType() == F->getFunctionType() && "wrong type?");
 
     // Get the mapped basic block...
     Function::iterator CBI = CMF->begin();
@@ -337,10 +338,10 @@
     // module, and that they don't include any deleted blocks.
     BBs.clear();
     for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
-      SymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
-      SymbolTable::plane_iterator PI = ST.find(Type::LabelTy);
-      if (PI != ST.plane_end() && PI->second.count(BlockInfo[i].second))
-        BBs.push_back(cast<BasicBlock>(PI->second[BlockInfo[i].second]));
+      ValueSymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
+      Value* V = ST.lookup(BlockInfo[i].second);
+      if (V && V->getType() == Type::LabelTy)
+        BBs.push_back(cast<BasicBlock>(V));
     }
     return true;
   }
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index b9d43e8..1ff06f8 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -110,7 +110,6 @@
     I->setLinkage(GlobalValue::ExternalLinkage);
 
   std::vector<const PassInfo*> CleanupPasses;
-  CleanupPasses.push_back(getPI(createFunctionResolvingPass()));
   CleanupPasses.push_back(getPI(createGlobalDCEPass()));
   CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
 
@@ -221,7 +220,7 @@
           M1Tors.push_back(std::make_pair(F, Priority));
         else {
           // Map to M2's version of the function.
-          F = M2->getFunction(F->getName(), F->getFunctionType());
+          F = M2->getFunction(F->getName());
           M2Tors.push_back(std::make_pair(F, Priority));
         }
       }
@@ -272,9 +271,10 @@
   std::set<std::pair<std::string, const PointerType*> > TestFunctions;
   for (unsigned i = 0, e = F.size(); i != e; ++i) {
     TestFunctions.insert(std::make_pair(F[i]->getName(), F[i]->getType()));  
-    Function *TNOF = M->getFunction(F[i]->getName(), F[i]->getFunctionType());
-    DEBUG(std::cerr << "Removing function " << F[i]->getName() << "\n");
+    Function *TNOF = M->getFunction(F[i]->getName());
     assert(TNOF && "Function doesn't exist in module!");
+    assert(TNOF->getFunctionType() == F[i]->getFunctionType() && "wrong type?");
+    DEBUG(std::cerr << "Removing function " << F[i]->getName() << "\n");
     DeleteFunctionBody(TNOF);       // Function is now external in this module!
   }
 
@@ -317,7 +317,7 @@
     Function *F = BB->getParent();
 
     // Map the corresponding function in this module.
-    Function *MF = M.getFunction(F->getName(), F->getFunctionType());
+    Function *MF = M.getFunction(F->getName());
 
     // Figure out which index the basic block is in its function.
     Function::iterator BBI = MF->begin();
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index bdbd11b..38ccf0b 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -341,9 +341,11 @@
     // optimized and loop extracted module.
     MiscompiledFunctions.clear();
     for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) {
-      Function *NewF = ToNotOptimize->getFunction(MisCompFunctions[i].first,
-                                                  MisCompFunctions[i].second);
+      Function *NewF = ToNotOptimize->getFunction(MisCompFunctions[i].first);
+                                                  
       assert(NewF && "Function not found??");
+      assert(NewF->getFunctionType() == MisCompFunctions[i].second && 
+             "found wrong function type?");
       MiscompiledFunctions.push_back(NewF);
     }
 
@@ -479,9 +481,10 @@
   MiscompiledFunctions.clear();
 
   for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) {
-    Function *NewF = ProgClone->getFunction(MisCompFunctions[i].first,
-                                            MisCompFunctions[i].second);
+    Function *NewF = ProgClone->getFunction(MisCompFunctions[i].first);
     assert(NewF && "Function not found??");
+    assert(NewF->getFunctionType() == MisCompFunctions[i].second && 
+           "Function has wrong type??");
     MiscompiledFunctions.push_back(NewF);
   }