summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-09-18 23:04:18 +0000
committerBill Wendling <isanbard@gmail.com>2008-09-18 23:04:18 +0000
commit670ed09238453f2d6614086b0a2d72bed180a8d2 (patch)
tree6b450446420589aa646b411904f2d88d0ae90162 /lib/Transforms
parent3d0a9a371c0ce3a46e845a7bf1f1acb7a1cf523e (diff)
downloadllvm-670ed09238453f2d6614086b0a2d72bed180a8d2.tar.gz
llvm-670ed09238453f2d6614086b0a2d72bed180a8d2.tar.bz2
llvm-670ed09238453f2d6614086b0a2d72bed180a8d2.tar.xz
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
Diffstat (limited to 'lib/Transforms')
-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;