@@ -31,31 +31,46 @@ using LoadStorePair = std::pair<Instruction *, Instruction *>;
31
31
// / Instrumentation based profiling lowering pass. This pass lowers
32
32
// / the profile instrumented code generated by FE or the IR based
33
33
// / 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
+
35
40
public:
36
- InstrProfiling () : IsCS( false ) {}
37
- InstrProfiling (const InstrProfOptions &Options, bool IsCS = false )
41
+ InstrProfilingLoweringPass () = default ;
42
+ InstrProfilingLoweringPass (const InstrProfOptions &Options, bool IsCS = false )
38
43
: Options(Options), IsCS(IsCS) {}
39
44
40
45
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 ();
43
57
44
58
private:
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
+
48
65
std::function<const TargetLibraryInfo &(Function &F)> GetTLI;
49
66
struct PerFunctionProfileData {
50
- uint32_t NumValueSites[IPVK_Last + 1 ];
67
+ uint32_t NumValueSites[IPVK_Last + 1 ] = {} ;
51
68
GlobalVariable *RegionCounters = nullptr ;
52
69
GlobalVariable *DataVar = nullptr ;
53
70
GlobalVariable *RegionBitmaps = nullptr ;
54
71
uint32_t NumBitmapBytes = 0 ;
55
72
56
- PerFunctionProfileData () {
57
- memset (NumValueSites, 0 , sizeof (uint32_t ) * (IPVK_Last + 1 ));
58
- }
73
+ PerFunctionProfileData () = default ;
59
74
};
60
75
DenseMap<GlobalVariable *, PerFunctionProfileData> ProfileDataMap;
61
76
// / If runtime relocation is enabled, this maps functions to the load
@@ -64,11 +79,8 @@ class InstrProfiling : public PassInfoMixin<InstrProfiling> {
64
79
std::vector<GlobalValue *> CompilerUsedVars;
65
80
std::vector<GlobalValue *> UsedVars;
66
81
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 ;
72
84
73
85
// vector of counter load/store pairs to be register promoted.
74
86
std::vector<LoadStorePair> PromotionCandidates;
0 commit comments