llvm.org GIT mirror llvm / db85e38
Count CallInsts correctly, remove unneccesary initializers S: ---------------------------------------------------------------------- git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4721 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 3 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
7373 inline void visitBranchInst(BranchInst &I) { NumBranchInst++; }
7474 inline void visitPHINode(PHINode &I) { NumPHINode++; }
7575 inline void visitCastInst (CastInst &I) { NumCastInst++; }
76 inline void visitCallInst (CallInst &I) { NumCastInst++; }
76 inline void visitCallInst (CallInst &I) { NumCallInst++; }
7777 inline void visitMallocInst(MallocInst &I) { NumMallocInst++; }
7878 inline void visitAllocaInst(AllocaInst &I) { NumAllocaInst++; }
7979 inline void visitFreeInst (FreeInst &I) { NumFreeInst++; }
9494 }
9595 };
9696
97 RegisterOpt X("instcount",
98 "Counts the various types of Instructions");
97 RegisterAnalysis X("instcount",
98 "Counts the various types of Instructions");
9999
100100 }
101101
107107 // function.
108108 //
109109 bool InstCount::run(Module &M) {
110 /* Initialization */
111 NumReturnInst = 0;
112 NumBranchInst = 0;
113 NumPHINode = 0;
114 NumCastInst = 0;
115 NumCallInst = 0;
116 NumMallocInst = 0;
117 NumAllocaInst = 0;
118 NumFreeInst = 0;
119 NumLoadInst = 0;
120 NumStoreInst = 0;
121 NumGetElementPtrInst = 0;
122 NumSwitchInst = 0;
123 NumInvokeInst = 0;
124 NumBinaryOperator = 0;
125 NumShiftInst = 0;
126 NumShlInst = 0;
127 NumShrInst = 0;
128 NumAddInst = 0;
129 NumSubInst = 0;
130 NumMulInst = 0;
131 NumDivInst = 0;
132 NumRemInst = 0;
133 NumAndInst = 0;
134 NumOrInst = 0;
135 NumXorInst = 0;
136 NumSetCondInst = 0;
137 NumSetEQInst = 0;
138 NumSetNEInst = 0;
139 NumSetLEInst = 0;
140 NumSetGEInst = 0;
141 NumSetLTInst = 0;
142 NumSetGTInst = 0;
143
144110 for (Module::iterator mI = M.begin(), mE = M.end(); mI != mE; ++mI)
145111 for (inst_iterator I = inst_begin(*mI), E = inst_end(*mI); I != E; ++I)
146112 visit(*I);