aboutsummaryrefslogtreecommitdiff
path: root/tools/bugpoint/ExtractFunction.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-08-10 15:46:11 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-08-10 15:46:11 +0000
commit866aa0d742b7bc9811fd1b45507af999c605205a (patch)
treece989cf4f563f84b47f7ff036fb29b96ec318ac9 /tools/bugpoint/ExtractFunction.cpp
parent6455384fc1c2328a656035810b895447bdddea0e (diff)
Use RunPassesOn as in the rest of bugpoint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/ExtractFunction.cpp')
-rw-r--r--tools/bugpoint/ExtractFunction.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 4e63e1698e..7d3040255a 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -55,13 +55,14 @@ namespace {
/// depends on the value. The modified module is then returned.
///
Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
- unsigned Simplification) const {
- Module *Result = CloneModule(Program);
+ unsigned Simplification) {
+ // FIXME, use vmap?
+ Module *Clone = CloneModule(Program);
const BasicBlock *PBB = I->getParent();
const Function *PF = PBB->getParent();
- Module::iterator RFI = Result->begin(); // Get iterator to corresponding fn
+ Module::iterator RFI = Clone->begin(); // Get iterator to corresponding fn
std::advance(RFI, std::distance(PF->getParent()->begin(),
Module::const_iterator(PF)));
@@ -79,24 +80,23 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
// Remove the instruction from the program.
TheInst->getParent()->getInstList().erase(TheInst);
-
- //writeProgramToFile("current.bc", Result);
-
// Spiff up the output a little bit.
- PassManager Passes;
- // Make sure that the appropriate target data is always used...
- Passes.add(new TargetData(Result));
+ std::vector<std::string> Passes;
- /// FIXME: If this used runPasses() like the methods below, we could get rid
- /// of the -disable-* options!
+ /// Can we get rid of the -disable-* options?
if (Simplification > 1 && !NoDCE)
- Passes.add(createDeadCodeEliminationPass());
+ Passes.push_back("dce");
if (Simplification && !DisableSimplifyCFG)
- Passes.add(createCFGSimplificationPass()); // Delete dead control flow
-
- Passes.add(createVerifierPass());
- Passes.run(*Result);
- return Result;
+ Passes.push_back("simplifycfg"); // Delete dead control flow
+
+ Passes.push_back("verify");
+ Module *New = runPassesOn(Clone, Passes);
+ delete Clone;
+ if (!New) {
+ errs() << "Instruction removal failed. Sorry. :( Please report a bug!\n";
+ exit(1);
+ }
+ return New;
}
/// performFinalCleanups - This method clones the current Program and performs