Skip to content

Commit 2f5ec13

Browse files
[Transforms] Migrate to a new version of getValueProfDataFromInst (llvm#95442)
Note that the version of getValueProfDataFromInst that returns bool has been "deprecated" since: commit 1e15371 Author: Mingming Liu <[email protected]> Date: Mon Apr 1 15:14:49 2024 -0700 --------- Co-authored-by: Mingming Liu <[email protected]>
1 parent a4f6b7d commit 2f5ec13

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ class MemOPSizeOpt : public InstVisitor<MemOPSizeOpt> {
177177
MemOPSizeOpt(Function &Func, BlockFrequencyInfo &BFI,
178178
OptimizationRemarkEmitter &ORE, DominatorTree *DT,
179179
TargetLibraryInfo &TLI)
180-
: Func(Func), BFI(BFI), ORE(ORE), DT(DT), TLI(TLI), Changed(false) {
181-
ValueDataArray =
182-
std::make_unique<InstrProfValueData[]>(INSTR_PROF_NUM_BUCKETS);
183-
}
180+
: Func(Func), BFI(BFI), ORE(ORE), DT(DT), TLI(TLI), Changed(false) {}
184181
bool isChanged() const { return Changed; }
185182
void perform() {
186183
WorkList.clear();
@@ -222,8 +219,6 @@ class MemOPSizeOpt : public InstVisitor<MemOPSizeOpt> {
222219
TargetLibraryInfo &TLI;
223220
bool Changed;
224221
std::vector<MemOp> WorkList;
225-
// The space to read the profile annotation.
226-
std::unique_ptr<InstrProfValueData[]> ValueDataArray;
227222
bool perform(MemOp MO);
228223
};
229224

@@ -252,10 +247,12 @@ bool MemOPSizeOpt::perform(MemOp MO) {
252247
if (!MemOPOptMemcmpBcmp && (MO.isMemcmp(TLI) || MO.isBcmp(TLI)))
253248
return false;
254249

255-
uint32_t NumVals, MaxNumVals = INSTR_PROF_NUM_BUCKETS;
250+
uint32_t NumVals = INSTR_PROF_NUM_BUCKETS;
251+
uint32_t MaxNumVals = INSTR_PROF_NUM_BUCKETS;
256252
uint64_t TotalCount;
257-
if (!getValueProfDataFromInst(*MO.I, IPVK_MemOPSize, MaxNumVals,
258-
ValueDataArray.get(), NumVals, TotalCount))
253+
auto ValueDataArray = getValueProfDataFromInst(
254+
*MO.I, IPVK_MemOPSize, MaxNumVals, NumVals, TotalCount);
255+
if (!ValueDataArray)
259256
return false;
260257

261258
uint64_t ActualCount = TotalCount;

0 commit comments

Comments
 (0)