* We were forgetting to pass varargs arguments through a call
[oota-llvm.git] / lib / Transforms / Scalar / GCSE.cpp
index b467784b5e1d1640931ef08a9258fa24b701d2bb..caf68bc1c8def5b544bfeacff94e5bddfbe677f1 100644 (file)
@@ -1,4 +1,11 @@
 //===-- GCSE.cpp - SSA based Global Common Subexpr Elimination ------------===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This pass is designed to be a very quick global transformation that
 // eliminates global common subexpressions from a function.  It does this by
@@ -120,6 +127,7 @@ bool GCSE::EliminateRedundancies(Instruction *I,
 
           // Erase the instruction from the program.
           I->getParent()->getInstList().erase(I);
+          WorkList.erase(I);
         }
       
       return true;
@@ -192,7 +200,7 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) {
   Instruction *Ret = 0;
 
   if (BB1 == BB2) {
-    // Eliminate the second occuring instruction.  Add all uses of the second
+    // Eliminate the second occurring instruction.  Add all uses of the second
     // instruction to the worklist.
     //
     // Scan the basic block looking for the "first" instruction
@@ -241,7 +249,7 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) {
     //    ... X+Y ...
     //  }
     // 
-    // In thiscase, the expression would be hoisted to outside the 'if' stmt,
+    // In this case, the expression would be hoisted to outside the 'if' stmt,
     // causing the expression to be evaluated, even for the if (d) path, which
     // could cause problems, if, for example, it caused a divide by zero.  In
     // general the problem this case is trying to solve is better addressed with