Skip to content

Commit 836ca5b

Browse files
[Transforms] Migrate to a new version of getValueProfDataFromInst (llvm#95485)
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
1 parent cb021f5 commit 836ca5b

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -790,14 +790,12 @@ SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
790790
static bool doesHistoryAllowICP(const Instruction &Inst, StringRef Candidate) {
791791
uint32_t NumVals = 0;
792792
uint64_t TotalCount = 0;
793-
std::unique_ptr<InstrProfValueData[]> ValueData =
794-
std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
795-
bool Valid =
793+
auto ValueData =
796794
getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
797-
ValueData.get(), NumVals, TotalCount, true);
795+
NumVals, TotalCount, true);
798796
// No valid value profile so no promoted targets have been recorded
799797
// before. Ok to do ICP.
800-
if (!Valid)
798+
if (!ValueData)
801799
return true;
802800

803801
unsigned NumPromoted = 0;
@@ -837,11 +835,8 @@ updateIDTMetaData(Instruction &Inst,
837835
uint32_t NumVals = 0;
838836
// OldSum is the existing total count in the value profile data.
839837
uint64_t OldSum = 0;
840-
std::unique_ptr<InstrProfValueData[]> ValueData =
841-
std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
842-
bool Valid =
843-
getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
844-
ValueData.get(), NumVals, OldSum, true);
838+
auto ValueData = getValueProfDataFromInst(
839+
Inst, IPVK_IndirectCallTarget, MaxNumPromotions, NumVals, OldSum, true);
845840

846841
DenseMap<uint64_t, uint64_t> ValueCountMap;
847842
if (Sum == 0) {
@@ -850,7 +845,7 @@ updateIDTMetaData(Instruction &Inst,
850845
"If sum is 0, assume only one element in CallTargets "
851846
"with count being NOMORE_ICP_MAGICNUM");
852847
// Initialize ValueCountMap with existing value profile data.
853-
if (Valid) {
848+
if (ValueData) {
854849
for (uint32_t I = 0; I < NumVals; I++)
855850
ValueCountMap[ValueData[I].Value] = ValueData[I].Count;
856851
}
@@ -866,7 +861,7 @@ updateIDTMetaData(Instruction &Inst,
866861
} else {
867862
// Initialize ValueCountMap with existing NOMORE_ICP_MAGICNUM
868863
// counts in the value profile.
869-
if (Valid) {
864+
if (ValueData) {
870865
for (uint32_t I = 0; I < NumVals; I++) {
871866
if (ValueData[I].Count == NOMORE_ICP_MAGICNUM)
872867
ValueCountMap[ValueData[I].Value] = ValueData[I].Count;

0 commit comments

Comments
 (0)