Don't corrupt memory when removing an instruction from the program, but
not the worklist


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6733 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp
index b467784..6883818 100644
--- a/lib/Transforms/Scalar/GCSE.cpp
+++ b/lib/Transforms/Scalar/GCSE.cpp
@@ -120,6 +120,7 @@
 
           // Erase the instruction from the program.
           I->getParent()->getInstList().erase(I);
+          WorkList.erase(I);
         }
       
       return true;