[llvm-commits] CVS: llvm/lib/Analysis/InstCount.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Dec 7 17:25:01 PST 2002


Changes in directory llvm/lib/Analysis:

InstCount.cpp updated: 1.3 -> 1.4

---
Log message:

Add total instruction, bb, & function counts


---
Diffs of the changes:

Index: llvm/lib/Analysis/InstCount.cpp
diff -u llvm/lib/Analysis/InstCount.cpp:1.3 llvm/lib/Analysis/InstCount.cpp:1.4
--- llvm/lib/Analysis/InstCount.cpp:1.3	Tue Dec  3 13:40:16 2002
+++ llvm/lib/Analysis/InstCount.cpp	Sat Dec  7 17:24:24 2002
@@ -10,6 +10,10 @@
 #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 @@
   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 @@
     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 {}
 
   };
 





More information about the llvm-commits mailing list