llvm.org GIT mirror llvm / a1af8bd
Add total instruction, bb, & function counts git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4954 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 9 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
99 #include "Support/Statistic.h"
1010
1111 namespace {
12 Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)");
13 Statistic<> TotalBlocks("instcount", "Number of basic blocks");
14 Statistic<> TotalFuncs ("instcount", "Number of non-external functions");
15
1216 #define HANDLE_INST(N, OPCODE, CLASS) \
1317 Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts");
1418
1721 class InstCount : public Pass, public InstVisitor {
1822 friend class InstVisitor;
1923
24 void visitFunction (Function &F) { ++TotalFuncs; }
25 void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
26
2027 #define HANDLE_INST(N, OPCODE, CLASS) \
21 void visit##OPCODE(CLASS &) { Num##OPCODE##Inst++; }
28 void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; }
2229
2330 #include "llvm/Instruction.def"
2431
3239 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
3340 AU.setPreservesAll();
3441 }
35 virtual void print(std::ostream &O, Module *M) const {}
42 virtual void print(std::ostream &O, const Module *M) const {}
3643
3744 };
3845