split ssa updating code out to its own helper function. Don't bother
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 26d32604adc086ff01bd98d9fdcdc118482845e7..664c3f6a222f7df19f6ddd74bb03da8780059abf 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     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 file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -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 {
-    static const char ID; // Pass identifcation, replacement for typeid
-    ConstantPropagation() : FunctionPass((intptr_t)&ID) {}
+  struct ConstantPropagation : public FunctionPass {
+    static char ID; // Pass identification, replacement for typeid
+    ConstantPropagation() : FunctionPass(ID) {
+      initializeConstantPropagationPass(*PassRegistry::getPassRegistry());
+    }
 
     bool runOnFunction(Function &F);
 
@@ -43,12 +44,12 @@ namespace {
       AU.setPreservesCFG();
     }
   };
-
-  const 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;