diff --git a/tools/bugpoint/CodeGeneratorBug.cpp b/tools/bugpoint/CodeGeneratorBug.cpp index 10f544a69ad..0aea9b031da 100644 --- a/tools/bugpoint/CodeGeneratorBug.cpp +++ b/tools/bugpoint/CodeGeneratorBug.cpp @@ -144,8 +144,8 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector &Funcs, ResolverArgs.push_back(GEP); // Insert code at the beginning of the function - for (Value::use_iterator i=F->use_begin(), e=F->use_end(); i!=e; ++i) { - if (Instruction* Inst = dyn_cast(*i)) { + while (!F->use_empty()) + if (Instruction *Inst = dyn_cast(F->use_back())) { // call resolver(GetElementPtr...) CallInst *resolve = new CallInst(resolverFunc, ResolverArgs, "resolver", Inst); @@ -161,7 +161,6 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector &Funcs, std::cerr << "Non-instruction is using an external function!\n"; abort(); } - } } } }