[llvm] [Analysis] Clean up getPromotionCandidatesForInstruction (NFC) (PR #95624)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 16:55:08 PDT 2024


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

Callers of getPromotionCandidatesForInstruction pass NumVals as an out
parameter for the number of value-count pairs of the value profiling
data, but nobody uses the out parameter.

This patch removes the parameter and updates the callers.  Note that
the number of value-count pairs is still available via
getPromotionCandidatesForInstruction(...).size().

>From dec53a7ab7a59648eca2f8a3b74f64bd9978d370 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 14 Jun 2024 16:25:21 -0700
Subject: [PATCH] [Analysis] Clean up getPromotionCandidatesForInstruction
 (NFC)

Callers of getPromotionCandidatesForInstruction pass NumVals as an out
parameter for the number of value-count pairs of the value profiling
data, but nobody uses the out parameter.

This patch removes the parameter and updates the callers.  Note that
the number of value-count pairs is still available via
getPromotionCandidatesForInstruction(...).size().
---
 llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h  | 6 ++----
 llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp         | 4 ++--
 llvm/lib/Analysis/ModuleSummaryAnalysis.cpp                 | 6 +++---
 .../Transforms/Instrumentation/IndirectCallPromotion.cpp    | 4 ++--
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h b/llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h
index 8a05e913a9106..e0e8a7cda9369 100644
--- a/llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h
+++ b/llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h
@@ -57,10 +57,8 @@ class ICallPromotionAnalysis {
   ///
   /// The returned array space is owned by this class, and overwritten on
   /// subsequent calls.
-  ArrayRef<InstrProfValueData>
-  getPromotionCandidatesForInstruction(const Instruction *I, uint32_t &NumVals,
-                                       uint64_t &TotalCount,
-                                       uint32_t &NumCandidates);
+  ArrayRef<InstrProfValueData> getPromotionCandidatesForInstruction(
+      const Instruction *I, uint64_t &TotalCount, uint32_t &NumCandidates);
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
index 84b0a1b2a5387..a71ab23a30902 100644
--- a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
+++ b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
@@ -89,8 +89,8 @@ uint32_t ICallPromotionAnalysis::getProfitablePromotionCandidates(
 
 ArrayRef<InstrProfValueData>
 ICallPromotionAnalysis::getPromotionCandidatesForInstruction(
-    const Instruction *I, uint32_t &NumVals, uint64_t &TotalCount,
-    uint32_t &NumCandidates) {
+    const Instruction *I, uint64_t &TotalCount, uint32_t &NumCandidates) {
+  uint32_t NumVals;
   auto Res = getValueProfDataFromInst(*I, IPVK_IndirectCallTarget,
                                       MaxNumPromotions, NumVals, TotalCount);
   if (!Res) {
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index a9913773fd13e..c6934f55ee114 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -483,11 +483,11 @@ static void computeFunctionSummary(
           }
         }
 
-        uint32_t NumVals, NumCandidates;
+        uint32_t NumCandidates;
         uint64_t TotalCount;
         auto CandidateProfileData =
-            ICallAnalysis.getPromotionCandidatesForInstruction(
-                &I, NumVals, TotalCount, NumCandidates);
+            ICallAnalysis.getPromotionCandidatesForInstruction(&I, TotalCount,
+                                                               NumCandidates);
         for (const auto &Candidate : CandidateProfileData)
           CallGraphEdges[Index.getOrInsertValueInfo(Candidate.Value)]
               .updateHotness(getHotness(Candidate.Count, PSI));
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index 6db76ca78b218..bb8019b5c31d8 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -315,10 +315,10 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) {
   bool Changed = false;
   ICallPromotionAnalysis ICallAnalysis;
   for (auto *CB : findIndirectCalls(F)) {
-    uint32_t NumVals, NumCandidates;
+    uint32_t NumCandidates;
     uint64_t TotalCount;
     auto ICallProfDataRef = ICallAnalysis.getPromotionCandidatesForInstruction(
-        CB, NumVals, TotalCount, NumCandidates);
+        CB, TotalCount, NumCandidates);
     if (!NumCandidates ||
         (PSI && PSI->hasProfileSummary() && !PSI->isHotCount(TotalCount)))
       continue;



More information about the llvm-commits mailing list