@@ -101,27 +101,23 @@ bool ProfileSummaryInfo::computeSummary() {
101
101
return true ;
102
102
}
103
103
104
- // FIXME(CallSite): the parameter should be a CallBase.
105
- Optional<uint64_t >
106
- ProfileSummaryInfo::getProfileCount (const Instruction *Inst,
107
- BlockFrequencyInfo *BFI,
108
- bool AllowSynthetic) {
109
- if (!Inst)
110
- return None;
111
- assert ((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
104
+ Optional<uint64_t > ProfileSummaryInfo::getProfileCount (const CallBase &Call,
105
+ BlockFrequencyInfo *BFI,
106
+ bool AllowSynthetic) {
107
+ assert ((isa<CallInst>(Call) || isa<InvokeInst>(Call)) &&
112
108
" We can only get profile count for call/invoke instruction." );
113
109
if (hasSampleProfile ()) {
114
110
// In sample PGO mode, check if there is a profile metadata on the
115
111
// instruction. If it is present, determine hotness solely based on that,
116
112
// since the sampled entry count may not be accurate. If there is no
117
113
// annotated on the instruction, return None.
118
114
uint64_t TotalCount;
119
- if (Inst-> extractProfTotalWeight (TotalCount))
115
+ if (Call. extractProfTotalWeight (TotalCount))
120
116
return TotalCount;
121
117
return None;
122
118
}
123
119
if (BFI)
124
- return BFI->getBlockProfileCount (Inst-> getParent (), AllowSynthetic);
120
+ return BFI->getBlockProfileCount (Call. getParent (), AllowSynthetic);
125
121
return None;
126
122
}
127
123
@@ -156,7 +152,7 @@ bool ProfileSummaryInfo::isFunctionHotInCallGraph(const Function *F,
156
152
for (const auto &BB : *F)
157
153
for (const auto &I : BB)
158
154
if (isa<CallInst>(I) || isa<InvokeInst>(I))
159
- if (auto CallCount = getProfileCount (&I , nullptr ))
155
+ if (auto CallCount = getProfileCount (cast<CallBase>(I) , nullptr ))
160
156
TotalCallCount += CallCount.getValue ();
161
157
if (isHotCount (TotalCallCount))
162
158
return true ;
@@ -185,7 +181,7 @@ bool ProfileSummaryInfo::isFunctionColdInCallGraph(const Function *F,
185
181
for (const auto &BB : *F)
186
182
for (const auto &I : BB)
187
183
if (isa<CallInst>(I) || isa<InvokeInst>(I))
188
- if (auto CallCount = getProfileCount (&I , nullptr ))
184
+ if (auto CallCount = getProfileCount (cast<CallBase>(I) , nullptr ))
189
185
TotalCallCount += CallCount.getValue ();
190
186
if (!isColdCount (TotalCallCount))
191
187
return false ;
@@ -214,7 +210,7 @@ bool ProfileSummaryInfo::isFunctionHotOrColdInCallGraphNthPercentile(
214
210
for (const auto &BB : *F)
215
211
for (const auto &I : BB)
216
212
if (isa<CallInst>(I) || isa<InvokeInst>(I))
217
- if (auto CallCount = getProfileCount (&I , nullptr ))
213
+ if (auto CallCount = getProfileCount (cast<CallBase>(I) , nullptr ))
218
214
TotalCallCount += CallCount.getValue ();
219
215
if (isHot && isHotCountNthPercentile (PercentileCutoff, TotalCallCount))
220
216
return true ;
@@ -388,13 +384,13 @@ bool ProfileSummaryInfo::isColdBlockNthPercentile(int PercentileCutoff,
388
384
389
385
bool ProfileSummaryInfo::isHotCallSite (const CallBase &CB,
390
386
BlockFrequencyInfo *BFI) {
391
- auto C = getProfileCount (& CB, BFI);
387
+ auto C = getProfileCount (CB, BFI);
392
388
return C && isHotCount (*C);
393
389
}
394
390
395
391
bool ProfileSummaryInfo::isColdCallSite (const CallBase &CB,
396
392
BlockFrequencyInfo *BFI) {
397
- auto C = getProfileCount (& CB, BFI);
393
+ auto C = getProfileCount (CB, BFI);
398
394
if (C)
399
395
return isColdCount (*C);
400
396
0 commit comments