Fix an iterator invalidation problem in a "buggy" pass

llvm-svn: 12468
This commit is contained in:
Chris Lattner 2004-03-17 17:29:08 +00:00
parent 2820235689
commit 425726d9c2
1 changed files with 2 additions and 1 deletions

View File

@ -44,7 +44,7 @@ namespace {
namespace {
/// DeleteCalls - This pass is used to test bugpoint. It intentionally
/// deletes all call instructions, "misoptimizing" the program.
/// deletes some call instructions, "misoptimizing" the program.
class DeleteCalls : public BasicBlockPass {
bool runOnBasicBlock(BasicBlock &BB) {
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
@ -52,6 +52,7 @@ namespace {
if (!CI->use_empty())
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
CI->getParent()->getInstList().erase(CI);
break;
}
return false;
}