[llvm] a07909f - [IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst (#97357)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 19:01:13 PDT 2024


Author: Kazu Hirata
Date: 2024-07-01T19:01:10-07:00
New Revision: a07909ff11327baa72a4644dca7c6951ac6be902

URL: https://github.com/llvm/llvm-project/commit/a07909ff11327baa72a4644dca7c6951ac6be902
DIFF: https://github.com/llvm/llvm-project/commit/a07909ff11327baa72a4644dca7c6951ac6be902.diff

LOG: [IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst (#97357)

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp

Removed: 
    


################################################################################
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