Skip to content

[ProfileData] Remove the old version of getValueProfDataFromInst #97374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions llvm/include/llvm/ProfileData/InstrProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,6 @@ void annotateValueSite(Module &M, Instruction &Inst,
ArrayRef<InstrProfValueData> VDs, uint64_t Sum,
InstrProfValueKind ValueKind, uint32_t MaxMDCount);

/// Extract the value profile data from \p Inst and returns them if \p Inst is
/// annotated with value profile data. Returns nullptr otherwise. It's similar
/// to `getValueProfDataFromInst` above except that an array is allocated only
/// after a preliminary checking that the value profiles of kind `ValueKind`
/// exist.
std::unique_ptr<InstrProfValueData[]>
getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
uint64_t &TotalC, bool GetNoICPValue = false);

// TODO: Unify metadata name 'PGOFuncName' and 'PGOName', by supporting read
// of this metadata for backward compatibility and generating 'PGOName' only.
/// Extract the value profile data from \p Inst and returns them if \p Inst is
Expand Down
45 changes: 0 additions & 45 deletions llvm/lib/ProfileData/InstrProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,51 +1342,6 @@ MDNode *mayHaveValueProfileOfKind(const Instruction &Inst,
return MD;
}

static bool getValueProfDataFromInstImpl(const MDNode *const MD,
const uint32_t MaxNumDataWant,
InstrProfValueData ValueData[],
uint32_t &ActualNumValueData,
uint64_t &TotalC, bool GetNoICPValue) {
const unsigned NOps = MD->getNumOperands();
// Get total count
ConstantInt *TotalCInt = mdconst::dyn_extract<ConstantInt>(MD->getOperand(2));
if (!TotalCInt)
return false;
TotalC = TotalCInt->getZExtValue();
ActualNumValueData = 0;

for (unsigned I = 3; I < NOps; I += 2) {
if (ActualNumValueData >= MaxNumDataWant)
break;
ConstantInt *Value = mdconst::dyn_extract<ConstantInt>(MD->getOperand(I));
ConstantInt *Count =
mdconst::dyn_extract<ConstantInt>(MD->getOperand(I + 1));
if (!Value || !Count)
return false;
uint64_t CntValue = Count->getZExtValue();
if (!GetNoICPValue && (CntValue == NOMORE_ICP_MAGICNUM))
continue;
ValueData[ActualNumValueData].Value = Value->getZExtValue();
ValueData[ActualNumValueData].Count = CntValue;
ActualNumValueData++;
}
return true;
}

std::unique_ptr<InstrProfValueData[]>
getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
uint64_t &TotalC, bool GetNoICPValue) {
MDNode *MD = mayHaveValueProfileOfKind(Inst, ValueKind);
if (!MD)
return nullptr;
auto ValueDataArray = std::make_unique<InstrProfValueData[]>(MaxNumValueData);
if (!getValueProfDataFromInstImpl(MD, MaxNumValueData, ValueDataArray.get(),
ActualNumValueData, TotalC, GetNoICPValue))
return nullptr;
return ValueDataArray;
}

SmallVector<InstrProfValueData, 4>
getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
uint32_t MaxNumValueData, uint64_t &TotalC,
Expand Down
Loading