summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/DCE.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index cb78207d76..fb9a0e04fd 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -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;