svn mv Target/ARM/ARMGlobalMerge.cpp Transforms/Scalar/GlobalMerge.cpp
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 60b915a1b5e43baf2478999389f25059b552cf72..664c3f6a222f7df19f6ddd74bb03da8780059abf 100644 (file)
@@ -14,7 +14,7 @@
 //
 // Notice that:
 //   * This pass has a habit of making definitions be dead.  It is a good idea
-//     to to run a DIE pass sometime after running this pass.
+//     to run a DIE pass sometime after running this pass.
 //
 //===----------------------------------------------------------------------===//
 
@@ -24,7 +24,6 @@
 #include "llvm/Constant.h"
 #include "llvm/Instruction.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/Compiler.h"
 #include "llvm/Support/InstIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include <set>
@@ -33,9 +32,11 @@ using namespace llvm;
 STATISTIC(NumInstKilled, "Number of instructions killed");
 
 namespace {
-  struct VISIBILITY_HIDDEN ConstantPropagation : public FunctionPass {
+  struct ConstantPropagation : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
-    ConstantPropagation() : FunctionPass((intptr_t)&ID) {}
+    ConstantPropagation() : FunctionPass(ID) {
+      initializeConstantPropagationPass(*PassRegistry::getPassRegistry());
+    }
 
     bool runOnFunction(Function &F);
 
@@ -43,12 +44,12 @@ namespace {
       AU.setPreservesCFG();
     }
   };
-
-  char ConstantPropagation::ID = 0;
-  RegisterPass<ConstantPropagation> X("constprop",
-                                      "Simple constant propagation");
 }
 
+char ConstantPropagation::ID = 0;
+INITIALIZE_PASS(ConstantPropagation, "constprop",
+                "Simple constant propagation", false, false)
+
 FunctionPass *llvm::createConstantPropagationPass() {
   return new ConstantPropagation();
 }
@@ -79,7 +80,7 @@ bool ConstantPropagation::runOnFunction(Function &F) {
 
         // Remove the dead instruction.
         WorkList.erase(I);
-        I->getParent()->getInstList().erase(I);
+        I->eraseFromParent();
 
         // We made a change to the function...
         Changed = true;