Use CloneModule's ValueMap to avoid needing to look up
authorDan Gohman <gohman@apple.com>
Fri, 6 Mar 2009 02:16:23 +0000 (02:16 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 6 Mar 2009 02:16:23 +0000 (02:16 +0000)
functions by name. This fixes PR718.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66239 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/CrashDebugger.cpp

index c290042d4c8db4c843cc42a77f43eb8761603d22..ba12621ad93a4fd50b7b5e869dc09db9d10fe07c 100644 (file)
@@ -198,17 +198,16 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
     return false;
 
   // Clone the program to try hacking it apart...
-  Module *M = CloneModule(BD.getProgram());
+  DenseMap<const Value*, Value*> ValueMap;
+  Module *M = CloneModule(BD.getProgram(), ValueMap);
 
   // Convert list to set for fast lookup...
   std::set<Function*> Functions;
   for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
-    // 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());
+    Function *CMF = cast<Function>(ValueMap[Funcs[i]]);
     assert(CMF && "Function not in module?!");
     assert(CMF->getFunctionType() == Funcs[i]->getFunctionType() && "wrong ty");
+    assert(CMF->getName() == Funcs[i]->getName() && "wrong name");
     Functions.insert(CMF);
   }