14 #define DEBUG_TYPE "instcount"
25 STATISTIC(TotalInsts ,
"Number of instructions (of all types)");
26 STATISTIC(TotalBlocks,
"Number of basic blocks");
27 STATISTIC(TotalFuncs ,
"Number of non-external functions");
28 STATISTIC(TotalMemInst,
"Number of memory instructions");
30 #define HANDLE_INST(N, OPCODE, CLASS) \
31 STATISTIC(Num ## OPCODE ## Inst, "Number of " #OPCODE " insts");
33 #include "llvm/IR/Instruction.def"
40 void visitFunction (
Function &
F) { ++TotalFuncs; }
41 void visitBasicBlock(
BasicBlock &BB) { ++TotalBlocks; }
43 #define HANDLE_INST(N, OPCODE, CLASS) \
44 void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; }
46 #include "llvm/IR/Instruction.def"
49 errs() <<
"Instruction Count does not know about " <<
I;
70 "Counts the various types of Instructions",
false,
true)
77 bool InstCount::runOnFunction(
Function &
F) {
78 unsigned StartMemInsts =
79 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
80 NumInvokeInst + NumAllocaInst;
82 unsigned EndMemInsts =
83 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
84 NumInvokeInst + NumAllocaInst;
85 TotalMemInst += EndMemInsts-StartMemInsts;
FunctionPass * createInstCountPass()
static PassRegistry * getPassRegistry()
Base class for instruction visitors.
The main container class for the LLVM Intermediate Representation.
STATISTIC(TotalInsts,"Number of instructions (of all types)")
void initializeInstCountPass(PassRegistry &)
#define llvm_unreachable(msg)
ID
LLVM Calling Convention Representation.
LLVM Basic Block Representation.
INITIALIZE_PASS(InstCount,"instcount","Counts the various types of Instructions", false, true) FunctionPass *llvm