summaryrefslogtreecommitdiff
path: root/tools
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
parent6455384fc1c2328a656035810b895447bdddea0e (diff)
downloadllvm-866aa0d742b7bc9811fd1b45507af999c605205a.tar.gz
llvm-866aa0d742b7bc9811fd1b45507af999c605205a.tar.bz2
llvm-866aa0d742b7bc9811fd1b45507af999c605205a.tar.xz
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')
-rw-r--r--tools/bugpoint/BugDriver.h3
-rw-r--r--tools/bugpoint/CrashDebugger.cpp23
-rw-r--r--tools/bugpoint/ExtractFunction.cpp34
3 files changed, 34 insertions, 26 deletions
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index dbb7a3dd8f..e48806aee6 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -214,8 +214,7 @@ public:
/// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code
/// which depends on the value. The modified module is then returned.
///
- Module *deleteInstructionFromProgram(const Instruction *I, unsigned Simp)
- const;
+ Module *deleteInstructionFromProgram(const Instruction *I, unsigned Simp);
/// performFinalCleanups - This method clones the current Program and performs
/// a series of cleanups intended to get rid of extra cruft on the module. If
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 2f73d9a58c..57dc1c830c 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -312,17 +312,24 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// a "persistent mapping" by turning basic blocks into <function, name> pairs.
// This won't work well if blocks are unnamed, but that is just the risk we
// have to take.
- std::vector<std::pair<Function*, std::string> > BlockInfo;
+ std::vector<std::pair<std::string, std::string> > BlockInfo;
for (SmallPtrSet<BasicBlock*, 8>::iterator I = Blocks.begin(),
E = Blocks.end(); I != E; ++I)
- BlockInfo.push_back(std::make_pair((*I)->getParent(), (*I)->getName()));
+ BlockInfo.push_back(std::make_pair((*I)->getParent()->getName(),
+ (*I)->getName()));
// Now run the CFG simplify pass on the function...
- PassManager Passes;
- Passes.add(createCFGSimplificationPass());
- Passes.add(createVerifierPass());
- Passes.run(*M);
+ std::vector<std::string> Passes;
+ Passes.push_back("simplifycfg");
+ Passes.push_back("verify");
+ Module *New = BD.runPassesOn(M, Passes);
+ delete M;
+ if (!New) {
+ errs() << "simplifycfg failed!\n";
+ exit(1);
+ }
+ M = New;
// Try running on the hacked up program...
if (TestFn(BD, M)) {
@@ -331,8 +338,10 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// Make sure to use basic block pointers that point into the now-current
// module, and that they don't include any deleted blocks.
BBs.clear();
+ const ValueSymbolTable &GST = M->getValueSymbolTable();
for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
- ValueSymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
+ Function *F = cast<Function>(GST.lookup(BlockInfo[i].first));
+ ValueSymbolTable &ST = F->getValueSymbolTable();
Value* V = ST.lookup(BlockInfo[i].second);
if (V && V->getType() == Type::getLabelTy(V->getContext()))
BBs.push_back(cast<BasicBlock>(V));
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