Skip to content

Commit a07909f

Browse files
[IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst (llvm#97357)
1 parent 0330ce9 commit a07909f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,18 +547,17 @@ Instruction *IndirectCallPromoter::computeVTableInfos(
547547
for (size_t I = 0; I < Candidates.size(); I++)
548548
CalleeIndexMap[Candidates[I].TargetFunction] = I;
549549

550-
uint32_t ActualNumValueData = 0;
551550
uint64_t TotalVTableCount = 0;
552-
auto VTableValueDataArray = getValueProfDataFromInst(
553-
*VirtualCallInfo.VPtr, IPVK_VTableTarget, MaxNumVTableAnnotations,
554-
ActualNumValueData, TotalVTableCount);
555-
if (VTableValueDataArray.get() == nullptr)
551+
auto VTableValueDataArray =
552+
getValueProfDataFromInst(*VirtualCallInfo.VPtr, IPVK_VTableTarget,
553+
MaxNumVTableAnnotations, TotalVTableCount);
554+
if (VTableValueDataArray.empty())
556555
return VPtr;
557556

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

0 commit comments

Comments
 (0)