Add total instruction, bb, & function counts
authorChris Lattner <sabre@nondot.org>
Sat, 7 Dec 2002 23:24:24 +0000 (23:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 7 Dec 2002 23:24:24 +0000 (23:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4954 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InstCount.cpp

index 0d84cc8c4fda3649c556cd79d027c83cb216ede6..18e0b9aceae389bf1d4b8fa0ebf4ece8dcedee46 100644 (file)
 #include "Support/Statistic.h"
 
 namespace {
+  Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)");
+  Statistic<> TotalBlocks("instcount", "Number of basic blocks");
+  Statistic<> TotalFuncs ("instcount", "Number of non-external functions");
+
 #define HANDLE_INST(N, OPCODE, CLASS) \
     Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts");
 
@@ -18,8 +22,11 @@ namespace {
   class InstCount : public Pass, public InstVisitor<InstCount> {
     friend class InstVisitor<InstCount>;
 
+    void visitFunction  (Function &F) { ++TotalFuncs; }
+    void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
+
 #define HANDLE_INST(N, OPCODE, CLASS) \
-    void visit##OPCODE(CLASS &) { Num##OPCODE##Inst++; }
+    void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; }
 
 #include "llvm/Instruction.def"
 
@@ -33,7 +40,7 @@ namespace {
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.setPreservesAll();
     }
-    virtual void print(std::ostream &O, Module *M) const {}
+    virtual void print(std::ostream &O, const Module *M) const {}
 
   };