[llvm] [IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst (PR #97357)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 15:22:12 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97357
None
>From f42f79534df31830f8df2b1a304ffbaa34023ad1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 1 Jul 2024 15:06:44 -0700
Subject: [PATCH] [IndirectCallPromotion] Migrate to a new version of
getValueProfDataFromInst
---
.../Instrumentation/IndirectCallPromotion.cpp | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
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));
}
More information about the llvm-commits
mailing list