mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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
This commit is contained in:
parent
6455384fc1
commit
866aa0d742
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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.push_back("simplifycfg"); // Delete dead control flow
|
||||
|
||||
Passes.add(createVerifierPass());
|
||||
Passes.run(*Result);
|
||||
return Result;
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user