llvm.org GIT mirror llvm / 6ae7e98
Directly count the number of memory instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20766 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 15 years ago
1 changed file(s) with 9 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1414 #include "llvm/Function.h"
1515 #include "llvm/Support/InstVisitor.h"
1616 #include "llvm/ADT/Statistic.h"
17
18 namespace llvm {
17 using namespace llvm;
1918
2019 namespace {
2120 Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)");
2221 Statistic<> TotalBlocks("instcount", "Number of basic blocks");
2322 Statistic<> TotalFuncs ("instcount", "Number of non-external functions");
23 Statistic<> TotalMemInst("instcount", "Number of memory instructions");
2424
2525 #define HANDLE_INST(N, OPCODE, CLASS) \
2626 Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts");
6060 // function.
6161 //
6262 bool InstCount::runOnFunction(Function &F) {
63 unsigned StartMemInsts =
64 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
65 NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst;
6366 visit(F);
67 unsigned EndMemInsts =
68 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
69 NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst;
70 TotalMemInst += EndMemInsts-StartMemInsts;
6471 return false;
6572 }
66
67 } // End llvm namespace