Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison lib/Analysis/InstCount.cpp @ 77:54457678186b
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | 803732b1fca8 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
9 // | 9 // |
10 // This pass collects the count of all instructions and reports them | 10 // This pass collects the count of all instructions and reports them |
11 // | 11 // |
12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
13 | 13 |
14 #define DEBUG_TYPE "instcount" | |
15 #include "llvm/Analysis/Passes.h" | 14 #include "llvm/Analysis/Passes.h" |
16 #include "llvm/ADT/Statistic.h" | 15 #include "llvm/ADT/Statistic.h" |
17 #include "llvm/IR/Function.h" | 16 #include "llvm/IR/Function.h" |
18 #include "llvm/InstVisitor.h" | 17 #include "llvm/IR/InstVisitor.h" |
19 #include "llvm/Pass.h" | 18 #include "llvm/Pass.h" |
20 #include "llvm/Support/Debug.h" | 19 #include "llvm/Support/Debug.h" |
21 #include "llvm/Support/ErrorHandling.h" | 20 #include "llvm/Support/ErrorHandling.h" |
22 #include "llvm/Support/raw_ostream.h" | 21 #include "llvm/Support/raw_ostream.h" |
23 using namespace llvm; | 22 using namespace llvm; |
23 | |
24 #define DEBUG_TYPE "instcount" | |
24 | 25 |
25 STATISTIC(TotalInsts , "Number of instructions (of all types)"); | 26 STATISTIC(TotalInsts , "Number of instructions (of all types)"); |
26 STATISTIC(TotalBlocks, "Number of basic blocks"); | 27 STATISTIC(TotalBlocks, "Number of basic blocks"); |
27 STATISTIC(TotalFuncs , "Number of non-external functions"); | 28 STATISTIC(TotalFuncs , "Number of non-external functions"); |
28 STATISTIC(TotalMemInst, "Number of memory instructions"); | 29 STATISTIC(TotalMemInst, "Number of memory instructions"); |
45 | 46 |
46 #include "llvm/IR/Instruction.def" | 47 #include "llvm/IR/Instruction.def" |
47 | 48 |
48 void visitInstruction(Instruction &I) { | 49 void visitInstruction(Instruction &I) { |
49 errs() << "Instruction Count does not know about " << I; | 50 errs() << "Instruction Count does not know about " << I; |
50 llvm_unreachable(0); | 51 llvm_unreachable(nullptr); |
51 } | 52 } |
52 public: | 53 public: |
53 static char ID; // Pass identification, replacement for typeid | 54 static char ID; // Pass identification, replacement for typeid |
54 InstCount() : FunctionPass(ID) { | 55 InstCount() : FunctionPass(ID) { |
55 initializeInstCountPass(*PassRegistry::getPassRegistry()); | 56 initializeInstCountPass(*PassRegistry::getPassRegistry()); |
56 } | 57 } |
57 | 58 |
58 virtual bool runOnFunction(Function &F); | 59 bool runOnFunction(Function &F) override; |
59 | 60 |
60 virtual void getAnalysisUsage(AnalysisUsage &AU) const { | 61 void getAnalysisUsage(AnalysisUsage &AU) const override { |
61 AU.setPreservesAll(); | 62 AU.setPreservesAll(); |
62 } | 63 } |
63 virtual void print(raw_ostream &O, const Module *M) const {} | 64 void print(raw_ostream &O, const Module *M) const override {} |
64 | 65 |
65 }; | 66 }; |
66 } | 67 } |
67 | 68 |
68 char InstCount::ID = 0; | 69 char InstCount::ID = 0; |