Decrementing the iterator here could be wrong if the worklist is empty after the "erase".

Thanks to Ji Young Park for the patch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56316 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2008-09-18 23:04:18 +00:00
parent 3d0a9a371c
commit 670ed09238

View File

@ -111,11 +111,12 @@ bool DCE::runOnFunction(Function &F) {
// Remove the instruction from the worklist if it still exists in it.
for (std::vector<Instruction*>::iterator WI = WorkList.begin();
WI != WorkList.end(); ++WI)
if (*WI == I) {
WI != WorkList.end(); ) {
if (*WI == I)
WI = WorkList.erase(WI);
--WI;
}
else
++WI;
}
MadeChange = true;
++DCEEliminated;