InstCount.cpp (198396) | InstCount.cpp (198892) |
---|---|
1//===-- InstCount.cpp - Collects the count of all instructions ------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This pass collects the count of all instructions and reports them 11// 12//===----------------------------------------------------------------------===// 13 14#define DEBUG_TYPE "instcount" 15#include "llvm/Analysis/Passes.h" 16#include "llvm/Pass.h" 17#include "llvm/Function.h" | 1//===-- InstCount.cpp - Collects the count of all instructions ------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This pass collects the count of all instructions and reports them 11// 12//===----------------------------------------------------------------------===// 13 14#define DEBUG_TYPE "instcount" 15#include "llvm/Analysis/Passes.h" 16#include "llvm/Pass.h" 17#include "llvm/Function.h" |
18#include "llvm/Support/Compiler.h" | |
19#include "llvm/Support/ErrorHandling.h" 20#include "llvm/Support/InstVisitor.h" 21#include "llvm/Support/raw_ostream.h" 22#include "llvm/ADT/Statistic.h" 23using namespace llvm; 24 25STATISTIC(TotalInsts , "Number of instructions (of all types)"); 26STATISTIC(TotalBlocks, "Number of basic blocks"); 27STATISTIC(TotalFuncs , "Number of non-external functions"); 28STATISTIC(TotalMemInst, "Number of memory instructions"); 29 30#define HANDLE_INST(N, OPCODE, CLASS) \ 31 STATISTIC(Num ## OPCODE ## Inst, "Number of " #OPCODE " insts"); 32 33#include "llvm/Instruction.def" 34 35 36namespace { | 18#include "llvm/Support/ErrorHandling.h" 19#include "llvm/Support/InstVisitor.h" 20#include "llvm/Support/raw_ostream.h" 21#include "llvm/ADT/Statistic.h" 22using namespace llvm; 23 24STATISTIC(TotalInsts , "Number of instructions (of all types)"); 25STATISTIC(TotalBlocks, "Number of basic blocks"); 26STATISTIC(TotalFuncs , "Number of non-external functions"); 27STATISTIC(TotalMemInst, "Number of memory instructions"); 28 29#define HANDLE_INST(N, OPCODE, CLASS) \ 30 STATISTIC(Num ## OPCODE ## Inst, "Number of " #OPCODE " insts"); 31 32#include "llvm/Instruction.def" 33 34 35namespace { |
37 class VISIBILITY_HIDDEN InstCount 38 : public FunctionPass, public InstVisitor<InstCount> { | 36 class InstCount : public FunctionPass, public InstVisitor<InstCount> { |
39 friend class InstVisitor<InstCount>; 40 41 void visitFunction (Function &F) { ++TotalFuncs; } 42 void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; } 43 44#define HANDLE_INST(N, OPCODE, CLASS) \ 45 void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; } 46 --- 24 unchanged lines hidden (view full) --- 71FunctionPass *llvm::createInstCountPass() { return new InstCount(); } 72 73// InstCount::run - This is the main Analysis entry point for a 74// function. 75// 76bool InstCount::runOnFunction(Function &F) { 77 unsigned StartMemInsts = 78 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + | 37 friend class InstVisitor<InstCount>; 38 39 void visitFunction (Function &F) { ++TotalFuncs; } 40 void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; } 41 42#define HANDLE_INST(N, OPCODE, CLASS) \ 43 void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; } 44 --- 24 unchanged lines hidden (view full) --- 69FunctionPass *llvm::createInstCountPass() { return new InstCount(); } 70 71// InstCount::run - This is the main Analysis entry point for a 72// function. 73// 74bool InstCount::runOnFunction(Function &F) { 75 unsigned StartMemInsts = 76 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + |
79 NumInvokeInst + NumAllocaInst + NumFreeInst; | 77 NumInvokeInst + NumAllocaInst; |
80 visit(F); 81 unsigned EndMemInsts = 82 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + | 78 visit(F); 79 unsigned EndMemInsts = 80 NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + |
83 NumInvokeInst + NumAllocaInst + NumFreeInst; | 81 NumInvokeInst + NumAllocaInst; |
84 TotalMemInst += EndMemInsts-StartMemInsts; 85 return false; 86} | 82 TotalMemInst += EndMemInsts-StartMemInsts; 83 return false; 84} |