22#define DEBUG_TYPE "instcount"
25 "Number of instructions of all types (before optimizations)");
26STATISTIC(TotalInsts,
"Number of instructions of all types");
28 "Number of basic blocks (before optimizations)");
31 "Number of non-external functions (before optimizations)");
32STATISTIC(TotalFuncs,
"Number of non-external functions");
34 "Largest number of instructions in a single function (before "
37 "Largest number of instructions in a single function");
39 "Largest number of basic blocks in a single function (before "
42 "Largest number of basic blocks in a single function");
44#define HANDLE_INST(N, OPCODE, CLASS) \
45 STATISTIC(Num##OPCODE##InstPreOptimization, \
46 "Number of " #OPCODE " insts (before optimizations)"); \
47 STATISTIC(Num##OPCODE##Inst, "Number of " #OPCODE " insts");
49#include "llvm/IR/Instruction.def"
54 bool IsPreOptimization;
57 InstCount(
bool IsPreOptimization) : IsPreOptimization(IsPreOptimization) {}
60 if (IsPreOptimization) {
61 ++TotalFuncsPreOptimization;
62 LargestFunctionSizePreOptimization.updateMax(
F.getInstructionCount());
63 LargestFunctionBBCountPreOptimization.updateMax(
F.size());
66 LargestFunctionSize.updateMax(
F.getInstructionCount());
67 LargestFunctionBBCount.updateMax(
F.size());
72 if (IsPreOptimization)
73 ++TotalBlocksPreOptimization;
78#define HANDLE_INST(N, OPCODE, CLASS) \
79 void visit##OPCODE(CLASS &) { \
80 if (IsPreOptimization) { \
81 ++Num##OPCODE##InstPreOptimization; \
82 ++TotalInstsPreOptimization; \
84 ++Num##OPCODE##Inst; \
89#include "llvm/IR/Instruction.def"
92 errs() <<
"Instruction Count does not know about " <<
I;
102 InstCount(this->IsPreOptimization).visit(
F);
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.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
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.