@@ -31,31 +31,46 @@ using LoadStorePair = std::pair<Instruction *, Instruction *>;
3131// / Instrumentation based profiling lowering pass. This pass lowers
3232// / the profile instrumented code generated by FE or the IR based
3333// / instrumentation pass.
34- class InstrProfiling : public PassInfoMixin <InstrProfiling> {
34+ class InstrProfilingLoweringPass
35+ : public PassInfoMixin<InstrProfilingLoweringPass> {
36+ const InstrProfOptions Options;
37+ // Is this lowering for the context-sensitive instrumentation.
38+ const bool IsCS = false ;
39+
3540public:
36- InstrProfiling () : IsCS( false ) {}
37- InstrProfiling (const InstrProfOptions &Options, bool IsCS = false )
41+ InstrProfilingLoweringPass () = default ;
42+ InstrProfilingLoweringPass (const InstrProfOptions &Options, bool IsCS = false )
3843 : Options(Options), IsCS(IsCS) {}
3944
4045 PreservedAnalyses run (Module &M, ModuleAnalysisManager &AM);
41- bool run (Module &M,
42- std::function<const TargetLibraryInfo &(Function &F)> GetTLI);
46+ };
47+
48+ class InstrProfiling final {
49+ public:
50+ InstrProfiling (Module &M, const InstrProfOptions &Options,
51+ std::function<const TargetLibraryInfo &(Function &F)> GetTLI,
52+ bool IsCS)
53+ : M(M), Options(Options), TT(Triple(M.getTargetTriple())), IsCS(IsCS),
54+ GetTLI (GetTLI) {}
55+
56+ bool lower ();
4357
4458private:
45- InstrProfOptions Options;
46- Module *M;
47- Triple TT;
59+ Module &M;
60+ const InstrProfOptions Options;
61+ const Triple TT;
62+ // Is this lowering for the context-sensitive instrumentation.
63+ const bool IsCS;
64+
4865 std::function<const TargetLibraryInfo &(Function &F)> GetTLI;
4966 struct PerFunctionProfileData {
50- uint32_t NumValueSites[IPVK_Last + 1 ];
67+ uint32_t NumValueSites[IPVK_Last + 1 ] = {} ;
5168 GlobalVariable *RegionCounters = nullptr ;
5269 GlobalVariable *DataVar = nullptr ;
5370 GlobalVariable *RegionBitmaps = nullptr ;
5471 uint32_t NumBitmapBytes = 0 ;
5572
56- PerFunctionProfileData () {
57- memset (NumValueSites, 0 , sizeof (uint32_t ) * (IPVK_Last + 1 ));
58- }
73+ PerFunctionProfileData () = default ;
5974 };
6075 DenseMap<GlobalVariable *, PerFunctionProfileData> ProfileDataMap;
6176 // / If runtime relocation is enabled, this maps functions to the load
@@ -64,11 +79,8 @@ class InstrProfiling : public PassInfoMixin<InstrProfiling> {
6479 std::vector<GlobalValue *> CompilerUsedVars;
6580 std::vector<GlobalValue *> UsedVars;
6681 std::vector<GlobalVariable *> ReferencedNames;
67- GlobalVariable *NamesVar;
68- size_t NamesSize;
69-
70- // Is this lowering for the context-sensitive instrumentation.
71- bool IsCS;
82+ GlobalVariable *NamesVar = nullptr ;
83+ size_t NamesSize = 0 ;
7284
7385 // vector of counter load/store pairs to be register promoted.
7486 std::vector<LoadStorePair> PromotionCandidates;
0 commit comments