1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Directly count the number of memory instructions.

llvm-svn: 20766
This commit is contained in:
Chris Lattner 2005-03-22 03:55:10 +00:00
parent b847572d0e
commit f975e2350a

View File

@ -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