Skip to content

[IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst #97357

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
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
17 changes: 8 additions & 9 deletions llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,17 @@ Instruction *IndirectCallPromoter::computeVTableInfos(
for (size_t I = 0; I < Candidates.size(); I++)
CalleeIndexMap[Candidates[I].TargetFunction] = I;

uint32_t ActualNumValueData = 0;
uint64_t TotalVTableCount = 0;
auto VTableValueDataArray = getValueProfDataFromInst(
*VirtualCallInfo.VPtr, IPVK_VTableTarget, MaxNumVTableAnnotations,
ActualNumValueData, TotalVTableCount);
if (VTableValueDataArray.get() == nullptr)
auto VTableValueDataArray =
getValueProfDataFromInst(*VirtualCallInfo.VPtr, IPVK_VTableTarget,
MaxNumVTableAnnotations, TotalVTableCount);
if (VTableValueDataArray.empty())
return VPtr;

// Compute the functions and counts from by each vtable.
for (size_t j = 0; j < ActualNumValueData; j++) {
uint64_t VTableVal = VTableValueDataArray[j].Value;
GUIDCountsMap[VTableVal] = VTableValueDataArray[j].Count;
for (const auto &V : VTableValueDataArray) {
uint64_t VTableVal = V.Value;
GUIDCountsMap[VTableVal] = V.Count;
GlobalVariable *VTableVar = Symtab->getGlobalVariable(VTableVal);
if (!VTableVar) {
LLVM_DEBUG(dbgs() << " Cannot find vtable definition for " << VTableVal
Expand Down Expand Up @@ -586,7 +585,7 @@ Instruction *IndirectCallPromoter::computeVTableInfos(
// There shouldn't be duplicate GUIDs in one !prof metadata (except
// duplicated zeros), so assign counters directly won't cause overwrite or
// counter loss.
Candidate.VTableGUIDAndCounts[VTableVal] = VTableValueDataArray[j].Count;
Candidate.VTableGUIDAndCounts[VTableVal] = V.Count;
Candidate.AddressPoints.push_back(
getOrCreateVTableAddressPointVar(VTableVar, AddressPointOffset));
}
Expand Down
Loading