diff options
author | Bill Wendling <isanbard@gmail.com> | 2008-09-18 23:04:18 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2008-09-18 23:04:18 +0000 |
commit | a00fa322b19a058bbf9f1b2641146677dcc68259 (patch) | |
tree | 66b86ab4a6862268d624cb441d09722374a49625 | |
parent | 76b22c142016775030f55958890048ff0e06d557 (diff) | |
download | bcm5719-llvm-a00fa322b19a058bbf9f1b2641146677dcc68259.tar.gz bcm5719-llvm-a00fa322b19a058bbf9f1b2641146677dcc68259.zip |
Decrementing the iterator here could be wrong if the worklist is empty after the "erase".
Thanks to Ji Young Park for the patch!
llvm-svn: 56316
-rw-r--r-- | llvm/lib/Transforms/Scalar/DCE.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp index cb78207d760..fb9a0e04fd6 100644 --- a/llvm/lib/Transforms/Scalar/DCE.cpp +++ b/llvm/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; |