assert(0) -> LLVM_UNREACHABLE.
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 60b915a1b5e43baf2478999389f25059b552cf72..d92ebdae66bb8293cf0e44cde611a30a2c742f30 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.
 //
 //===----------------------------------------------------------------------===//
 
@@ -35,7 +35,7 @@ STATISTIC(NumInstKilled, "Number of instructions killed");
 namespace {
   struct VISIBILITY_HIDDEN ConstantPropagation : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
-    ConstantPropagation() : FunctionPass((intptr_t)&ID) {}
+    ConstantPropagation() : FunctionPass(&ID) {}
 
     bool runOnFunction(Function &F);
 
@@ -43,12 +43,12 @@ namespace {
       AU.setPreservesCFG();
     }
   };
-
-  char ConstantPropagation::ID = 0;
-  RegisterPass<ConstantPropagation> X("constprop",
-                                      "Simple constant propagation");
 }
 
+char ConstantPropagation::ID = 0;
+static RegisterPass<ConstantPropagation>
+X("constprop", "Simple constant propagation");
+
 FunctionPass *llvm::createConstantPropagationPass() {
   return new ConstantPropagation();
 }
@@ -67,7 +67,7 @@ bool ConstantPropagation::runOnFunction(Function &F) {
     WorkList.erase(WorkList.begin());    // Get an element from the worklist...
 
     if (!I->use_empty())                 // Don't muck with dead instructions...
-      if (Constant *C = ConstantFoldInstruction(I)) {
+      if (Constant *C = ConstantFoldInstruction(I, Context)) {
         // Add all of the users of this instruction to the worklist, they might
         // be constant propagatable now...
         for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
@@ -79,7 +79,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;