mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Directly count the number of memory instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20766 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fed1b27d32
commit
6ae7e9837c
@ -15,13 +15,13 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
|
using namespace llvm;
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)");
|
Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)");
|
||||||
Statistic<> TotalBlocks("instcount", "Number of basic blocks");
|
Statistic<> TotalBlocks("instcount", "Number of basic blocks");
|
||||||
Statistic<> TotalFuncs ("instcount", "Number of non-external functions");
|
Statistic<> TotalFuncs ("instcount", "Number of non-external functions");
|
||||||
|
Statistic<> TotalMemInst("instcount", "Number of memory instructions");
|
||||||
|
|
||||||
#define HANDLE_INST(N, OPCODE, CLASS) \
|
#define HANDLE_INST(N, OPCODE, CLASS) \
|
||||||
Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts");
|
Statistic<> Num##OPCODE##Inst("instcount", "Number of " #OPCODE " insts");
|
||||||
@ -61,8 +61,13 @@ namespace {
|
|||||||
// function.
|
// function.
|
||||||
//
|
//
|
||||||
bool InstCount::runOnFunction(Function &F) {
|
bool InstCount::runOnFunction(Function &F) {
|
||||||
|
unsigned StartMemInsts =
|
||||||
|
NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
|
||||||
|
NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst;
|
||||||
visit(F);
|
visit(F);
|
||||||
|
unsigned EndMemInsts =
|
||||||
|
NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
|
||||||
|
NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst;
|
||||||
|
TotalMemInst += EndMemInsts-StartMemInsts;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user