diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-14 21:17:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-14 21:17:22 +0000 |
commit | a75766a6c14b364b74b30546802e26d4b4b36a9b (patch) | |
tree | bd9d64e8dd2e32514285df487a927517d556b7f6 /tools | |
parent | 3b6441e1050a9a2a55c79f58513191b3195fdaf7 (diff) | |
download | external_llvm-a75766a6c14b364b74b30546802e26d4b4b36a9b.zip external_llvm-a75766a6c14b364b74b30546802e26d4b4b36a9b.tar.gz external_llvm-a75766a6c14b364b74b30546802e26d4b4b36a9b.tar.bz2 |
Refactor to use a new method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bugpoint/ExtractFunction.cpp | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 22bd173..53afd47 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -112,25 +112,13 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) { CleanupPasses.push_back(getPI(createDeadArgHackingPass())); else CleanupPasses.push_back(getPI(createDeadArgEliminationPass())); - - std::swap(Program, M); - std::string Filename; - bool Failed = runPasses(CleanupPasses, Filename); - std::swap(Program, M); - if (Failed) { + Module *New = runPassesOn(M, CleanupPasses); + if (New == 0) { std::cerr << "Final cleanups failed. Sorry. :( Please report a bug!\n"; - } else { - delete M; - M = ParseInputFile(Filename); - if (M == 0) { - std::cerr << getToolName() << ": Error reading bytecode file '" - << Filename << "'!\n"; - exit(1); - } - removeFile(Filename); } - return M; + delete M; + return New; } @@ -141,32 +129,20 @@ Module *BugDriver::ExtractLoop(Module *M) { std::vector<const PassInfo*> LoopExtractPasses; LoopExtractPasses.push_back(getPI(createSingleLoopExtractorPass())); - std::swap(Program, M); - std::string Filename; - bool Failed = runPasses(LoopExtractPasses, Filename); - std::swap(Program, M); - - if (Failed) { + Module *NewM = runPassesOn(M, LoopExtractPasses); + if (NewM == 0) { std::cerr << "Loop extraction failed. Sorry. :( Please report a bug!\n"; return 0; - } else { - Module *NewM = ParseInputFile(Filename); - if (NewM == 0) { - std::cerr << getToolName() << ": Error reading bytecode file '" - << Filename << "'!\n"; - exit(1); - } - removeFile(Filename); - - // Check to see if we created any new functions. If not, no loops were - // extracted and we should return null. - if (M->size() != NewM->size()) { - delete NewM; - return 0; - } - - return NewM; } + + // Check to see if we created any new functions. If not, no loops were + // extracted and we should return null. + if (M->size() != NewM->size()) { + delete NewM; + return 0; + } + + return NewM; } |