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 | a1af8bd72b783108ad950e22ba98a402a773111a (patch) | |
tree | bc5d91b31308c52557fee6a260437096a8ce88f1 | |
parent | ac8d4d9d59e8f84f457c9847b2a279edd23c1023 (diff) | |
download | external_llvm-a1af8bd72b783108ad950e22ba98a402a773111a.zip external_llvm-a1af8bd72b783108ad950e22ba98a402a773111a.tar.gz external_llvm-a1af8bd72b783108ad950e22ba98a402a773111a.tar.bz2 |
Add total instruction, bb, & function counts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4954 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/InstCount.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index 0d84cc8..18e0b9a 100644 --- a/lib/Analysis/InstCount.cpp +++ b/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 {} }; |