diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-12 02:43:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-12 02:43:24 +0000 |
commit | 49e4a33c9849de62a273bf99aa5205a1971e5ef7 (patch) | |
tree | d002beb9d340b961096ddd4f154661c37fb22da0 /llvm/tools | |
parent | b797a4f9680dd7e1c0a24385e62da636944e181c (diff) | |
download | bcm5719-llvm-49e4a33c9849de62a273bf99aa5205a1971e5ef7.tar.gz bcm5719-llvm-49e4a33c9849de62a273bf99aa5205a1971e5ef7.zip |
Implement the final missing bits for block extractor support. Now bugpoint
can extract basic blocks up to the limit of the block extractor implementation.
llvm-svn: 13475
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/bugpoint/Miscompilation.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp index adbc62d3eb9..4c957ac480e 100644 --- a/llvm/tools/bugpoint/Miscompilation.cpp +++ b/llvm/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; } |