diff options
author | Chris Lattner <sabre@nondot.org> | 2005-03-22 03:55:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-03-22 03:55:10 +0000 |
commit | f00684079a4d1693a46911c690cff98ab6cbc18d (patch) | |
tree | 6eb70a8d524f2caeaa46d7156672763a68705a50 /llvm/lib/Analysis/InstCount.cpp | |
parent | 24922c7a2bb2c046e2025af703b20d51329f9c97 (diff) | |
download | bcm5719-llvm-f00684079a4d1693a46911c690cff98ab6cbc18d.tar.gz bcm5719-llvm-f00684079a4d1693a46911c690cff98ab6cbc18d.zip |
Directly count the number of memory instructions.
llvm-svn: 20766
Diffstat (limited to 'llvm/lib/Analysis/InstCount.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstCount.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InstCount.cpp b/llvm/lib/Analysis/InstCount.cpp index 12d16b081e7..c3a12eeb241 100644 --- a/llvm/lib/Analysis/InstCount.cpp +++ b/llvm/lib/Analysis/InstCount.cpp @@ -15,13 +15,13 @@ #include "llvm/Function.h" #include "llvm/Support/InstVisitor.h" #include "llvm/ADT/Statistic.h" - -namespace llvm { +using namespace llvm; 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"); + Statistic<> TotalMemInst("instcount", "Number of memory instructions"); #define HANDLE_INST(N, OPCODE, CLASS) \ Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts"); @@ -61,8 +61,13 @@ namespace { // function. // bool InstCount::runOnFunction(Function &F) { + unsigned StartMemInsts = + NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + + NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst; visit(F); + unsigned EndMemInsts = + NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + + NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst; + TotalMemInst += EndMemInsts-StartMemInsts; return false; } - -} // End llvm namespace |