summaryrefslogtreecommitdiff
path: root/lib/Analysis/InstCount.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-22 03:55:10 +0000
committerChris Lattner <sabre@nondot.org>2005-03-22 03:55:10 +0000
commit6ae7e9837cd4261029d5a9d65ab8d3295b8884ed (patch)
tree58b4421f062fe52f0702cdcdd6c76a34e1c8ee08 /lib/Analysis/InstCount.cpp
parentfed1b27d323001682e7cb1bd66bb5d603cabb9f8 (diff)
Directly count the number of memory instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstCount.cpp')
-rw-r--r--lib/Analysis/InstCount.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp
index 12d16b081e7..c3a12eeb241 100644
--- a/lib/Analysis/InstCount.cpp
+++ b/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