[llvm] [Transforms] Migrate to a new version of getValueProfDataFromInst (PR #95477)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 14:37:01 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/95477

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

  commit 1e15371dd8843dfc52b9435afaa133997c1773d8
  Author: Mingming Liu <mingmingl at google.com>
  Date:   Mon Apr 1 15:14:49 2024 -0700

>From e714c8d14a5a15c2d3aa6d1c54d31794866bca79 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 12 Jun 2024 22:59:39 -0700
Subject: [PATCH] [Transforms] Migrate to a new version of
 getValueProfDataFromInst

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

  commit 1e15371dd8843dfc52b9435afaa133997c1773d8
  Author: Mingming Liu <mingmingl at google.com>
  Date:   Mon Apr 1 15:14:49 2024 -0700
---
 llvm/lib/Transforms/Instrumentation/CGProfile.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
index c322d0abd6bc1..651239bee91f9 100644
--- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
+++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
@@ -78,14 +78,14 @@ static bool runCGProfilePass(Module &M, FunctionAnalysisManager &FAM,
         if (!CB)
           continue;
         if (CB->isIndirectCall()) {
-          InstrProfValueData ValueData[8];
           uint32_t ActualNumValueData;
           uint64_t TotalC;
-          if (!getValueProfDataFromInst(*CB, IPVK_IndirectCallTarget, 8,
-                                        ValueData, ActualNumValueData, TotalC))
+          auto ValueData = getValueProfDataFromInst(
+              *CB, IPVK_IndirectCallTarget, 8, ActualNumValueData, TotalC);
+          if (!ValueData)
             continue;
-          for (const auto &VD :
-               ArrayRef<InstrProfValueData>(ValueData, ActualNumValueData)) {
+          for (const auto &VD : ArrayRef<InstrProfValueData>(
+                   ValueData.get(), ActualNumValueData)) {
             UpdateCounts(TTI, &F, Symtab.getFunction(VD.Value), VD.Count);
           }
           continue;



More information about the llvm-commits mailing list