[llvm] [IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst (PR #97357)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 15:22:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/97357.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (+8-9)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index 6a5aeeb8b52cc..0d1f506986379 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -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
@@ -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));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/97357
More information about the llvm-commits
mailing list