speed up steens by using spliceFrom, improve its precision by realizing that
[oota-llvm.git] / lib / Analysis / InstCount.cpp
index 96c255ba31147127a79b88b7b291c186cd93a15f..c3a12eeb241389768cd2f3745467d84e65cb853c 100644 (file)
 #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");
@@ -29,7 +29,7 @@ namespace {
 #include "llvm/Instruction.def"
 
   class InstCount : public FunctionPass, public InstVisitor<InstCount> {
-    friend struct InstVisitor<InstCount>;
+    friend class InstVisitor<InstCount>;
 
     void visitFunction  (Function &F) { ++TotalFuncs; }
     void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
@@ -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