aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-12 02:43:24 +0000
committerChris Lattner <sabre@nondot.org>2004-05-12 02:43:24 +0000
commit2290e754061f1393bb96b1808ac33dc03399c939 (patch)
treeccd6cc2c067eeb86badb34944f14c3fc9c949110
parent300e74b43fd75d240bea59049c3b729e3b0d9539 (diff)
Implement the final missing bits for block extractor support. Now bugpoint
can extract basic blocks up to the limit of the block extractor implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13475 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/bugpoint/Miscompilation.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index adbc62d3eb..4c957ac480 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -403,13 +403,46 @@ static bool ExtractBlocks(BugDriver &BD,
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;
}