Remove support for NOT instruction
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 7085ef98006e21a54625886c02415c6e6a355d1e..5da909e2020bc68ddaa04894ff7f84fdcf3b1067 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Transforms/Scalar/ConstantProp.h"
+#include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/ConstantHandling.h"
 #include "llvm/Instruction.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/InstIterator.h"
+#include "Support/StatisticReporter.h"
 #include <set>
 
+static Statistic<> NumInstKilled("constprop - Number of instructions killed");
+
 namespace {
   struct ConstantPropogation : public FunctionPass {
-    const char *getPassName() const { return "Simple Constant Propogation"; }
-
-    inline bool runOnFunction(Function *F);
+    bool runOnFunction(Function &F);
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.preservesCFG();
     }
   };
+
+  RegisterOpt<ConstantPropogation> X("constprop","Simple constant propogation");
 }
 
 Pass *createConstantPropogationPass() {
@@ -36,7 +39,7 @@ Pass *createConstantPropogationPass() {
 }
 
 
-bool ConstantPropogation::runOnFunction(Function *F) {
+bool ConstantPropogation::runOnFunction(Function &F) {
   // Initialize the worklist to all of the instructions ready to process...
   std::set<Instruction*> WorkList(inst_begin(F), inst_end(F));
   bool Changed = false;
@@ -55,9 +58,10 @@ bool ConstantPropogation::runOnFunction(Function *F) {
         
         // Replace all of the uses of a variable with uses of the constant.
         I->replaceAllUsesWith(C);
-        
+
         // We made a change to the function...
         Changed = true;
+        ++NumInstKilled;
       }
   }
   return Changed;