diff options
author | Chris Lattner <sabre@nondot.org> | 2002-12-07 23:24:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-12-07 23:24:24 +0000 |
commit | 3935d2b1ec200de9f55bb93e65638c1f98696477 (patch) | |
tree | ec41fd25a2b90b4a843c034e02d5c9eb290fa0fc /llvm/lib/Analysis/InstCount.cpp | |
parent | 1ee7f8e6bb52fe8d0a0056fae788276ddccb772d (diff) | |
download | bcm5719-llvm-3935d2b1ec200de9f55bb93e65638c1f98696477.tar.gz bcm5719-llvm-3935d2b1ec200de9f55bb93e65638c1f98696477.zip |
Add total instruction, bb, & function counts
llvm-svn: 4954
Diffstat (limited to 'llvm/lib/Analysis/InstCount.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstCount.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp index 0d84cc8c4fd..18e0b9aceae 100644 --- a/llvm/lib/Analysis/InstCount.cpp +++ b/llvm/lib/Analysis/InstCount.cpp @@ -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 @@ 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 {} }; |