Avoid deleting individual instructions until AFTER dead blocks have dropped
[oota-llvm.git] / lib / Transforms / Scalar / ConstantProp.cpp
index 7598afe32b318e6c47d71241c805e78ac9363de1..720266ce1874997793708a7eb64fe6c3da30fa9c 100644 (file)
 #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();
@@ -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;