[llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue May 11 21:43:01 PDT 2004


Changes in directory llvm/tools/bugpoint:

Miscompilation.cpp updated: 1.45 -> 1.46

---
Log message:

Implement the final missing bits for block extractor support.  Now bugpoint
can extract basic blocks up to the limit of the block extractor implementation.


---
Diffs of the changes:  (+35 -2)

Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.45 llvm/tools/bugpoint/Miscompilation.cpp:1.46
--- llvm/tools/bugpoint/Miscompilation.cpp:1.45	Tue May 11 16:54:13 2004
+++ llvm/tools/bugpoint/Miscompilation.cpp	Tue May 11 21:43:24 2004
@@ -403,13 +403,46 @@
   if (Blocks.size() == OldSize)
     return false;
 
+  Module *ProgClone = CloneModule(BD.getProgram());
+  Module *ToExtract = SplitFunctionsOutOfModule(ProgClone,
+                                                MiscompiledFunctions);
+  Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract);
+  if (Extracted == 0) {
+    // Wierd, extraction should have worked.
+    std::cerr << "Nondeterministic problem extracting blocks??\n";
+    delete ProgClone;
+    delete ToExtract;
+    return false;
+  }
 
+  // Otherwise, block extraction succeeded.  Link the two program fragments back
+  // together.
+  delete ToExtract;
 
-  // FIXME: This should actually update the module in the bugdriver!
+  std::string ErrorMsg;
+  if (LinkModules(ProgClone, Extracted, &ErrorMsg)) {
+    std::cerr << BD.getToolName() << ": Error linking modules together:"
+              << ErrorMsg << "\n";
+    exit(1);
+  }
 
+  // Set the new program and delete the old one.
+  BD.setNewProgram(ProgClone);
 
+  // Update the list of miscompiled functions.
+  MiscompiledFunctions.clear();
 
-  return false;
+  for (Module::iterator I = Extracted->begin(), E = Extracted->end(); I != E;
+       ++I)
+    if (!I->isExternal()) {
+      Function *NF = ProgClone->getFunction(I->getName(), I->getFunctionType());
+      assert(NF && "Mapped function not found!");
+      MiscompiledFunctions.push_back(NF);
+    }
+
+  delete Extracted;
+
+  return true;
 }
 
 





More information about the llvm-commits mailing list