LLVM: lib/Analysis/InstCount.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
20using namespace llvm;
21
22#define DEBUG_TYPE "instcount"
23
24STATISTIC(TotalInsts, "Number of instructions (of all types)");
25STATISTIC(TotalBlocks, "Number of basic blocks");
26STATISTIC(TotalFuncs, "Number of non-external functions");
27
28#define HANDLE_INST(N, OPCODE, CLASS) \
29 STATISTIC(Num##OPCODE##Inst, "Number of " #OPCODE " insts");
30
31#include "llvm/IR/Instruction.def"
32
33namespace {
34class InstCount : public InstVisitor {
36
37 void visitFunction(Function &F) { ++TotalFuncs; }
38 void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
39
40#define HANDLE_INST(N, OPCODE, CLASS) \
41 void visit##OPCODE(CLASS &) { \
42 ++Num##OPCODE##Inst; \
43 ++TotalInsts; \
44 }
45
46#include "llvm/IR/Instruction.def"
47
49 errs() << "Instruction Count does not know about " << I;
51 }
52};
53}
54
57 LLVM_DEBUG(dbgs() << "INSTCOUNT: running on function " << F.getName()
58 << "\n");
59 InstCount().visit(F);
60
62}
FunctionAnalysisManager FAM
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM Basic Block Representation.
Base class for instruction visitors.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Definition InstCount.cpp:55