[llvm-commits] [llvm] r56316 - /llvm/trunk/lib/Transforms/Scalar/DCE.cpp
Bill Wendling
isanbard at gmail.com
Thu Sep 18 16:04:19 PDT 2008
Author: void
Date: Thu Sep 18 18:04:18 2008
New Revision: 56316
URL: http://llvm.org/viewvc/llvm-project?rev=56316&view=rev
Log:
Decrementing the iterator here could be wrong if the worklist is empty after the "erase".
Thanks to Ji Young Park for the patch!
Modified:
llvm/trunk/lib/Transforms/Scalar/DCE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/DCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DCE.cpp?rev=56316&r1=56315&r2=56316&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DCE.cpp Thu Sep 18 18:04:18 2008
@@ -111,11 +111,12 @@
// 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;
More information about the llvm-commits
mailing list