1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

bugpoint: Remove implicit ilist iterator conversions, NFC

This is the last of the implicit ilist iterator conversions in LLVM.
Still up for debate whether we let these bitrot back:
http://lists.llvm.org/pipermail/llvm-dev/2015-October/091617.html

llvm-svn: 250852
This commit is contained in:
Duncan P. N. Exon Smith 2015-10-20 19:36:39 +00:00
parent 55e9c1f1f1
commit cc73874cf4
3 changed files with 47 additions and 56 deletions

View File

@ -155,11 +155,10 @@ ReduceCrashingGlobalVariables::TestGlobalVariables(
// Loop over and delete any global variables which we aren't supposed to be
// playing with...
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
if (I->hasInitializer() && !GVSet.count(I)) {
I->setInitializer(nullptr);
I->setLinkage(GlobalValue::ExternalLinkage);
for (GlobalVariable &I : M->globals())
if (I.hasInitializer() && !GVSet.count(&I)) {
I.setInitializer(nullptr);
I.setLinkage(GlobalValue::ExternalLinkage);
}
// Try running the hacked up program...
@ -253,9 +252,9 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
if (!ReplaceFuncsWithNull) {
// Loop over and delete any functions which we aren't supposed to be playing
// with...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (!I->isDeclaration() && !Functions.count(I))
DeleteFunctionBody(I);
for (Function &I : *M)
if (!I.isDeclaration() && !Functions.count(&I))
DeleteFunctionBody(&I);
} else {
std::vector<GlobalValue*> ToRemove;
// First, remove aliases to functions we're about to purge.
@ -280,12 +279,12 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
ToRemove.push_back(&Alias);
}
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
if (!I->isDeclaration() && !Functions.count(I)) {
PointerType *Ty = cast<PointerType>(I->getType());
for (Function &I : *M) {
if (!I.isDeclaration() && !Functions.count(&I)) {
PointerType *Ty = cast<PointerType>(I.getType());
Constant *Replacement = ConstantPointerNull::get(Ty);
I->replaceAllUsesWith(Replacement);
ToRemove.push_back(I);
I.replaceAllUsesWith(Replacement);
ToRemove.push_back(&I);
}
}
@ -361,11 +360,12 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// Loop over and delete any hack up any blocks that are not listed...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB)
if (!Blocks.count(BB) && BB->getTerminator()->getNumSuccessors()) {
if (!Blocks.count(&*BB) && BB->getTerminator()->getNumSuccessors()) {
// Loop over all of the successors of this block, deleting any PHI nodes
// that might include it.
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)
(*SI)->removePredecessor(BB);
for (succ_iterator SI = succ_begin(&*BB), E = succ_end(&*BB); SI != E;
++SI)
(*SI)->removePredecessor(&*BB);
TerminatorInst *BBTerm = BB->getTerminator();
@ -374,7 +374,7 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// Replace the old terminator instruction.
BB->getInstList().pop_back();
new UnreachableInst(BB->getContext(), BB);
new UnreachableInst(BB->getContext(), &*BB);
}
// The CFG Simplifier pass may delete one of the basic blocks we are
@ -468,7 +468,7 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) {
Instruction *Inst = I++;
Instruction *Inst = &*I++;
if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) &&
!Inst->isEHPad()) {
if (!Inst->getType()->isVoidTy())
@ -538,7 +538,7 @@ static bool DebugACrash(BugDriver &BD,
for (Module::global_iterator I = BD.getProgram()->global_begin(),
E = BD.getProgram()->global_end(); I != E; ++I)
if (I->hasInitializer())
GVs.push_back(I);
GVs.push_back(&*I);
if (GVs.size() > 1 && !BugpointIsInterrupted) {
outs() << "\n*** Attempting to reduce the number of global "
@ -558,10 +558,9 @@ static bool DebugACrash(BugDriver &BD,
// Now try to reduce the number of functions in the module to something small.
std::vector<Function*> Functions;
for (Module::iterator I = BD.getProgram()->begin(),
E = BD.getProgram()->end(); I != E; ++I)
if (!I->isDeclaration())
Functions.push_back(I);
for (Function &F : *BD.getProgram())
if (!F.isDeclaration())
Functions.push_back(&F);
if (Functions.size() > 1 && !BugpointIsInterrupted) {
outs() << "\n*** Attempting to reduce the number of functions "
@ -581,10 +580,9 @@ static bool DebugACrash(BugDriver &BD,
//
if (!DisableSimplifyCFG && !BugpointIsInterrupted) {
std::vector<const BasicBlock*> Blocks;
for (Module::const_iterator I = BD.getProgram()->begin(),
E = BD.getProgram()->end(); I != E; ++I)
for (Function::const_iterator FI = I->begin(), E = I->end(); FI !=E; ++FI)
Blocks.push_back(FI);
for (Function &F : *BD.getProgram())
for (BasicBlock &BB : F)
Blocks.push_back(&BB);
unsigned OldSize = Blocks.size();
ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks, Error);
if (Blocks.size() < OldSize)
@ -595,14 +593,11 @@ static bool DebugACrash(BugDriver &BD,
// cases with large basic blocks where the problem is at one end.
if (!BugpointIsInterrupted) {
std::vector<const Instruction*> Insts;
for (Module::const_iterator MI = BD.getProgram()->begin(),
ME = BD.getProgram()->end(); MI != ME; ++MI)
for (Function::const_iterator FI = MI->begin(), FE = MI->end(); FI != FE;
++FI)
for (BasicBlock::const_iterator I = FI->begin(), E = FI->end();
I != E; ++I)
if (!isa<TerminatorInst>(I))
Insts.push_back(I);
for (const Function &F : *BD.getProgram())
for (const BasicBlock &BB : F)
for (const Instruction &I : BB)
if (!isa<TerminatorInst>(&I))
Insts.push_back(&I);
ReduceCrashingInstructions(BD, TestFn).reduceList(Insts, Error);
}
@ -647,7 +642,7 @@ static bool DebugACrash(BugDriver &BD,
outs() << "Checking instruction: " << *I;
std::unique_ptr<Module> M =
BD.deleteInstructionFromProgram(I, Simplification);
BD.deleteInstructionFromProgram(&*I, Simplification);
// Find out if the pass still crashes on this pass...
if (TestFn(BD, M.get())) {

View File

@ -100,7 +100,7 @@ BugDriver::deleteInstructionFromProgram(const Instruction *I,
BasicBlock::iterator RI = RBI->begin(); // Get iterator to corresponding inst
std::advance(RI, std::distance(PBB->begin(), BasicBlock::const_iterator(I)));
Instruction *TheInst = RI; // Got the corresponding instruction!
Instruction *TheInst = &*RI; // Got the corresponding instruction!
// If this instruction produces a value, replace any users with null values
if (!TheInst->getType()->isVoidTy())
@ -306,16 +306,14 @@ llvm::SplitFunctionsOutOfModule(Module *M,
// Remove the Safe functions from the Test module
for (Module::iterator I = New->begin(), E = New->end(); I != E; ++I)
if (!TestFunctions.count(I))
DeleteFunctionBody(I);
for (Function &I : *New)
if (!TestFunctions.count(&I))
DeleteFunctionBody(&I);
// Try to split the global initializers evenly
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I) {
GlobalVariable *GV = cast<GlobalVariable>(NewVMap[I]);
if (Function *TestFn = globalInitUsesExternalBA(I)) {
for (GlobalVariable &I : M->globals()) {
GlobalVariable *GV = cast<GlobalVariable>(NewVMap[&I]);
if (Function *TestFn = globalInitUsesExternalBA(&I)) {
if (Function *SafeFn = globalInitUsesExternalBA(GV)) {
errs() << "*** Error: when reducing functions, encountered "
"the global '";
@ -325,7 +323,7 @@ llvm::SplitFunctionsOutOfModule(Module *M,
<< "' and from test function '" << TestFn->getName() << "'.\n";
exit(1);
}
I->setInitializer(nullptr); // Delete the initializer to make it external
I.setInitializer(nullptr); // Delete the initializer to make it external
} else {
// If we keep it in the safe module, then delete it in the test module
GV->setInitializer(nullptr);

View File

@ -545,9 +545,8 @@ static bool ExtractBlocks(BugDriver &BD,
std::vector<BasicBlock*> Blocks;
for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i)
for (Function::iterator I = MiscompiledFunctions[i]->begin(),
E = MiscompiledFunctions[i]->end(); I != E; ++I)
Blocks.push_back(I);
for (BasicBlock &BB : *MiscompiledFunctions[i])
Blocks.push_back(&BB);
// Use the list reducer to identify blocks that can be extracted without
// obscuring the bug. The Blocks list will end up containing blocks that must
@ -628,9 +627,9 @@ DebugAMiscompilation(BugDriver &BD,
// the program.
std::vector<Function*> MiscompiledFunctions;
Module *Prog = BD.getProgram();
for (Module::iterator I = Prog->begin(), E = Prog->end(); I != E; ++I)
if (!I->isDeclaration())
MiscompiledFunctions.push_back(I);
for (Function &F : *Prog)
if (!F.isDeclaration())
MiscompiledFunctions.push_back(&F);
// Do the reduction...
if (!BugpointIsInterrupted)
@ -802,7 +801,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
I = newMain->arg_begin(), E = newMain->arg_end(),
OI = oldMain->arg_begin(); I != E; ++I, ++OI) {
I->setName(OI->getName()); // Copy argument names from oldMain
args.push_back(I);
args.push_back(&*I);
}
// Call the old main function and return its result
@ -905,9 +904,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Save the argument list.
std::vector<Value*> Args;
for (Function::arg_iterator i = FuncWrapper->arg_begin(),
e = FuncWrapper->arg_end(); i != e; ++i)
Args.push_back(i);
for (Argument &A : FuncWrapper->args())
Args.push_back(&A);
// Pass on the arguments to the real function, return its result
if (F->getReturnType()->isVoidTy()) {