Add support for variable argument functions!
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 720266ce1874997793708a7eb64fe6c3da30fa9c..b7dde4a113e66c8f79832742b565c1efaf725c0d 100644 (file)
 #include "llvm/Instruction.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/InstIterator.h"
-#include "Support/StatisticReporter.h"
+#include "Support/Statistic.h"
 #include <set>
 
-static Statistic<> NumInstKilled("constprop - Number of instructions killed");
-
 namespace {
-  struct ConstantPropogation : public FunctionPass {
-    const char *getPassName() const { return "Simple Constant Propogation"; }
+  Statistic<> NumInstKilled("constprop", "Number of instructions killed");
 
-    bool runOnFunction(Function *F);
+  struct ConstantPropogation : public FunctionPass {
+    bool runOnFunction(Function &F);
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.preservesCFG();
+      AU.setPreservesCFG();
     }
   };
+
+  RegisterOpt<ConstantPropogation> X("constprop","Simple constant propogation");
 }
 
 Pass *createConstantPropogationPass() {
@@ -39,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;