@@ -35,32 +35,29 @@ using namespace psr;
3535
3636namespace psr {
3737
38- llvm::AnalysisKey GeneralStatisticsAnalysis::Key;
39-
40- GeneralStatisticsAnalysis::GeneralStatisticsAnalysis () = default ;
41-
38+ llvm::AnalysisKey GeneralStatisticsAnalysis::Key; // NOLINT
4239GeneralStatistics
4340GeneralStatisticsAnalysis::run (llvm::Module &M,
44- llvm::ModuleAnalysisManager &AM ) {
41+ llvm::ModuleAnalysisManager & /* AM */ ) {
4542 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
4643 << " Running GeneralStatisticsAnalysis" );
4744 static const std::set<std::string> MemAllocatingFunctions = {
4845 " operator new(unsigned long)" , " operator new[](unsigned long)" , " malloc" ,
4946 " calloc" , " realloc" };
5047 for (auto &F : M) {
51- ++Stats.functions ;
48+ ++Stats.Functions ;
5249 for (auto &BB : F) {
53- ++Stats.basicblocks ;
50+ ++Stats.BasicBlocks ;
5451 for (auto &I : BB) {
5552 // found one more instruction
56- ++Stats.instructions ;
53+ ++Stats.Instructions ;
5754 // check for alloca instruction for possible types
5855 if (const llvm::AllocaInst *Alloc =
5956 llvm::dyn_cast<llvm::AllocaInst>(&I)) {
60- Stats.allocatedTypes .insert (Alloc->getAllocatedType ());
57+ Stats.AllocatedTypes .insert (Alloc->getAllocatedType ());
6158 // do not add allocas from llvm internal functions
62- Stats.allocaInstructions .insert (&I);
63- ++Stats.allocationsites ;
59+ Stats.AllocaInstructions .insert (&I);
60+ ++Stats.AllocationSites ;
6461 } // check bitcast instructions for possible types
6562 else {
6663 for (auto *User : I.users ()) {
@@ -72,30 +69,30 @@ GeneralStatisticsAnalysis::run(llvm::Module &M,
7269 }
7370 // check for return or resume instructions
7471 if (llvm::isa<llvm::ReturnInst>(I) || llvm::isa<llvm::ResumeInst>(I)) {
75- Stats.retResInstructions .insert (&I);
72+ Stats.RetResInstructions .insert (&I);
7673 }
7774 // check for store instructions
7875 if (llvm::isa<llvm::StoreInst>(I)) {
79- ++Stats.storeInstructions ;
76+ ++Stats.StoreInstructions ;
8077 }
8178 // check for load instructions
8279 if (llvm::isa<llvm::LoadInst>(I)) {
83- ++Stats.loadInstructions ;
80+ ++Stats.LoadInstructions ;
8481 }
8582 // check for llvm's memory intrinsics
8683 if (llvm::isa<llvm::MemIntrinsic>(I)) {
87- ++Stats.memIntrinsic ;
84+ ++Stats.MemIntrinsics ;
8885 }
8986 // check for function calls
9087 if (llvm::isa<llvm::CallInst>(I) || llvm::isa<llvm::InvokeInst>(I)) {
91- ++Stats.callsites ;
88+ ++Stats.CallSites ;
9289 const llvm::CallBase *CallSite = llvm::cast<llvm::CallBase>(&I);
9390 if (CallSite->getCalledFunction ()) {
9491 if (MemAllocatingFunctions.count (llvm::demangle (
9592 CallSite->getCalledFunction ()->getName ().str ()))) {
9693 // do not add allocas from llvm internal functions
97- Stats.allocaInstructions .insert (&I);
98- ++Stats.allocationsites ;
94+ Stats.AllocaInstructions .insert (&I);
95+ ++Stats.AllocationSites ;
9996 // check if an instance of a user-defined type is allocated on the
10097 // heap
10198 for (auto *User : I.users ()) {
@@ -113,7 +110,7 @@ GeneralStatisticsAnalysis::run(llvm::Module &M,
113110 if (CTor->getCalledFunction () &&
114111 getNthFunctionArgument (CTor->getCalledFunction (), 0 )
115112 ->getType () == Cast->getDestTy ()) {
116- Stats.allocatedTypes .insert (
113+ Stats.AllocatedTypes .insert (
117114 Cast->getDestTy ()->getPointerElementType ());
118115 }
119116 }
@@ -130,9 +127,9 @@ GeneralStatisticsAnalysis::run(llvm::Module &M,
130127 // check for global pointers
131128 for (auto &Global : M.globals ()) {
132129 if (Global.getType ()->isPointerTy ()) {
133- ++Stats.globalPointers ;
130+ ++Stats.GlobalPointers ;
134131 }
135- ++Stats.globals ;
132+ ++Stats.Globals ;
136133 }
137134 // register stuff in PAMM
138135 // For performance reasons (and out of sheer convenience) we simply initialize
@@ -163,29 +160,29 @@ GeneralStatisticsAnalysis::run(llvm::Module &M,
163160 << " GeneralStatisticsAnalysis summary for module: '"
164161 << M.getName ().str () << " '" );
165162 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
166- << " Instructions : " << Stats.instructions );
163+ << " Instructions : " << Stats.Instructions );
167164 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
168- << " Allocated Types : " << Stats.allocatedTypes .size ());
165+ << " Allocated Types : " << Stats.AllocatedTypes .size ());
169166 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
170- << " Allocation Sites : " << Stats.allocationsites );
167+ << " Allocation Sites : " << Stats.AllocationSites );
171168 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
172- << " Basic Blocks : " << Stats.basicblocks );
169+ << " Basic Blocks : " << Stats.BasicBlocks );
173170 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
174- << " Calls Sites : " << Stats.callsites );
171+ << " Calls Sites : " << Stats.CallSites );
175172 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
176- << " Functions : " << Stats.functions );
173+ << " Functions : " << Stats.Functions );
177174 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
178- << " Globals : " << Stats.globals );
175+ << " Globals : " << Stats.Globals );
179176 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
180- << " Global Pointer : " << Stats.globalPointers );
177+ << " Global Pointer : " << Stats.GlobalPointers );
181178 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
182- << " Memory Intrinsics : " << Stats.memIntrinsic );
179+ << " Memory Intrinsics : " << Stats.MemIntrinsics );
183180 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
184- << " Store Instructions : " << Stats.storeInstructions );
181+ << " Store Instructions : " << Stats.StoreInstructions );
185182 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO) << ' ' );
186183 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), INFO)
187- << " Allocated Types << " << Stats.allocatedTypes .size ());
188- for (const auto *Type : Stats.allocatedTypes ) {
184+ << " Allocated Types << " << Stats.AllocatedTypes .size ());
185+ for (const auto *Type : Stats.AllocatedTypes ) {
189186 std::string TypeStr;
190187 llvm::raw_string_ostream Rso (TypeStr);
191188 Type->print (Rso);
@@ -196,38 +193,38 @@ GeneralStatisticsAnalysis::run(llvm::Module &M,
196193 return Stats;
197194}
198195
199- size_t GeneralStatistics::getAllocationsites () const { return allocationsites ; }
196+ size_t GeneralStatistics::getAllocationsites () const { return AllocationSites ; }
200197
201- size_t GeneralStatistics::getFunctioncalls () const { return callsites ; }
198+ size_t GeneralStatistics::getFunctioncalls () const { return CallSites ; }
202199
203- size_t GeneralStatistics::getInstructions () const { return instructions ; }
200+ size_t GeneralStatistics::getInstructions () const { return Instructions ; }
204201
205- size_t GeneralStatistics::getGlobalPointers () const { return globalPointers ; }
202+ size_t GeneralStatistics::getGlobalPointers () const { return GlobalPointers ; }
206203
207- size_t GeneralStatistics::getBasicBlocks () const { return basicblocks ; }
204+ size_t GeneralStatistics::getBasicBlocks () const { return BasicBlocks ; }
208205
209- size_t GeneralStatistics::getFunctions () const { return functions ; }
206+ size_t GeneralStatistics::getFunctions () const { return Functions ; }
210207
211- size_t GeneralStatistics::getGlobals () const { return globals ; }
208+ size_t GeneralStatistics::getGlobals () const { return Globals ; }
212209
213- size_t GeneralStatistics::getMemoryIntrinsics () const { return memIntrinsic ; }
210+ size_t GeneralStatistics::getMemoryIntrinsics () const { return MemIntrinsics ; }
214211
215212size_t GeneralStatistics::getStoreInstructions () const {
216- return storeInstructions ;
213+ return StoreInstructions ;
217214}
218215
219216set<const llvm::Type *> GeneralStatistics::getAllocatedTypes () const {
220- return allocatedTypes ;
217+ return AllocatedTypes ;
221218}
222219
223220set<const llvm::Instruction *>
224221GeneralStatistics::getAllocaInstructions () const {
225- return allocaInstructions ;
222+ return AllocaInstructions ;
226223}
227224
228225set<const llvm::Instruction *>
229226GeneralStatistics::getRetResInstructions () const {
230- return retResInstructions ;
227+ return RetResInstructions ;
231228}
232229
233230} // namespace psr
0 commit comments