diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-10 15:38:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-10 15:38:35 +0000 |
commit | 0b18c1d64e690b5472c310c1293434e00bb26524 (patch) | |
tree | 35b861e74e78c958a184e7f1849cdfcd34f28041 /llvm/lib/Transforms/Scalar/DCE.cpp | |
parent | bad1b4dfcea66f1c52c88cb9f81f3a768bb00f1b (diff) | |
download | bcm5719-llvm-0b18c1d64e690b5472c310c1293434e00bb26524.tar.gz bcm5719-llvm-0b18c1d64e690b5472c310c1293434e00bb26524.zip |
Add support for printing out statistics information when -stats is added to
the command line
llvm-svn: 2601
Diffstat (limited to 'llvm/lib/Transforms/Scalar/DCE.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/DCE.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp index 793b3abb6a3..2c9c8b3b0d5 100644 --- a/llvm/lib/Transforms/Scalar/DCE.cpp +++ b/llvm/lib/Transforms/Scalar/DCE.cpp @@ -14,8 +14,12 @@ #include "llvm/Instruction.h" #include "llvm/Pass.h" #include "llvm/Support/InstIterator.h" +#include "Support/StatisticReporter.h" #include <set> +static Statistic<> DIEEliminated("die\t\t- Number of insts removed"); +static Statistic<> DCEEliminated("dce\t\t- Number of insts removed"); + //===----------------------------------------------------------------------===// // DeadInstElimination pass implementation // @@ -28,9 +32,10 @@ namespace { BasicBlock::InstListType &Vals = BB->getInstList(); bool Changed = false; for (BasicBlock::iterator DI = Vals.begin(); DI != Vals.end(); ) - if (dceInstruction(Vals, DI)) + if (dceInstruction(Vals, DI)) { Changed = true; - else + ++DIEEliminated; + } else ++DI; return Changed; } @@ -103,6 +108,7 @@ bool DCE::runOnFunction(Function *F) { for (BasicBlock::iterator BI = BBIL.begin(); BI != BBIL.end(); ) if (DeadInsts.count(*BI)) { // Is this instruction dead? delete BBIL.remove(BI); // Yup, remove and delete inst + ++DCEEliminated; } else { // This instruction is not dead ++BI; // Continue on to the next one... } |