LLVM: lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
18
19namespace llvm {
20
22 "sample-profile-max-propagate-iterations", cl::init(100),
23 cl::desc("Maximum number of iterations to go through when propagating "
24 "sample block/edge weights through the CFG."));
25
28 cl::desc("Emit a warning if less than N% of records in the input profile "
29 "are matched to the IR."));
30
33 cl::desc("Emit a warning if less than N% of samples in the input profile "
34 "are matched to the IR."));
35
38 cl::desc("Use this option to turn off/on warnings about function with "
39 "samples but without debug information to use those samples. "));
40
42 "sample-profile-use-profi", cl::Hidden,
43 cl::desc("Use profi to infer block and edge counts."));
44
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
65 bool ProfAccForSymsInList) {
66 if (!CallsiteFS)
67 return false;
68
69 assert(PSI && "PSI is expected to be non null");
71 if (ProfAccForSymsInList)
72 return !PSI->isColdCount(CallsiteTotalSamples);
73 else
74 return PSI->isHotCount(CallsiteTotalSamples);
75}
76
77
78
79
80
86 unsigned &Count = SampleCoverage[FS][Loc];
87 bool FirstTime = (++Count == 1);
88 if (FirstTime)
89 TotalUsedSamples += Samples;
90 return FirstTime;
91}
92
93
94
95
96unsigned
99 auto I = SampleCoverage.find(FS);
100
101
102
103 unsigned Count = (I != SampleCoverage.end()) ? I->second.size() : 0;
104
105
106
107
108 for (const auto &I : FS->getCallsiteSamples())
109 for (const auto &J : I.second) {
111 if (callsiteIsHot(CalleeSamples, PSI, ProfAccForSymsInList))
113 }
114
116}
117
118
119
120
121unsigned
124 unsigned Count = FS->getBodySamples().size();
125
126
127 for (const auto &I : FS->getCallsiteSamples())
128 for (const auto &J : I.second) {
130 if (callsiteIsHot(CalleeSamples, PSI, ProfAccForSymsInList))
132 }
133
135}
136
137
138
139
144 for (const auto &I : FS->getBodySamples())
145 Total += I.second.getSamples();
146
147
148 for (const auto &I : FS->getCallsiteSamples())
149 for (const auto &J : I.second) {
151 if (callsiteIsHot(CalleeSamples, PSI, ProfAccForSymsInList))
153 }
154
156}
157
158
159
160
161
162
164 unsigned Total) const {
166 "number of used records cannot exceed the total number of records");
167 return Total > 0 ? Used * 100 / Total : 100;
168}
169
170
172 const char *FSDiscriminatorVar = "__llvm_fs_discriminator__";
173 if (M->getGlobalVariable(FSDiscriminatorVar))
174 return;
175
176 auto &Context = M->getContext();
177
181 FSDiscriminatorVar)});
182}
183
184}
185}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This file provides the utility functions for the sampled PGO loader base implementation.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
LLVM_ABI bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
LLVM_ABI bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Representation of the samples collected for a function.
uint64_t getTotalSamples() const
Return the total number of samples collected inside the function.
unsigned countBodyRecords(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of sample records in the body of this profile.
Definition SampleProfileLoaderBaseUtil.cpp:122
unsigned countUsedRecords(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of sample records that were applied from this profile.
Definition SampleProfileLoaderBaseUtil.cpp:97
unsigned computeCoverage(unsigned Used, unsigned Total) const
Return the fraction of sample records used in this profile.
Definition SampleProfileLoaderBaseUtil.cpp:163
uint64_t countBodySamples(const FunctionSamples *FS, ProfileSummaryInfo *PSI) const
Return the number of samples collected in the body of this profile.
Definition SampleProfileLoaderBaseUtil.cpp:141
bool markSamplesUsed(const FunctionSamples *FS, uint32_t LineOffset, uint32_t Discriminator, uint64_t Samples)
Mark as used the sample record for the given function samples at (LineOffset, Discriminator).
Definition SampleProfileLoaderBaseUtil.cpp:81
initializer< Ty > init(const Ty &Val)
void createFSDiscriminatorVariable(Module *M)
Create a global variable to flag FSDiscriminators are used.
Definition SampleProfileLoaderBaseUtil.cpp:171
bool callsiteIsHot(const FunctionSamples *CallsiteFS, ProfileSummaryInfo *PSI, bool ProfAccForSymsInList)
Return true if the given callsite is hot wrt to hot cutoff threshold.
Definition SampleProfileLoaderBaseUtil.cpp:64
This is an optimization pass for GlobalISel generic memory operations.
cl::opt< unsigned > SampleProfileSampleCoverage
cl::opt< unsigned > SampleProfileRecordCoverage
cl::opt< unsigned > SampleProfileMaxPropagateIterations
cl::opt< bool > SampleProfileUseProfi
FunctionAddr VTableAddr Count
cl::opt< bool > NoWarnSampleUnused
LLVM_ABI void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
Represents the relative location of an instruction.