[llvm] 2bdc0da - [ICP] Fix warnings

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 12:37:12 PDT 2024


Author: Kazu Hirata
Date: 2024-08-27T12:37:06-07:00
New Revision: 2bdc0da4d7a26ab023ee03b877fb4a3e4beb070c

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

LOG: [ICP] Fix warnings

This patch fixes:

  llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp:845:12:
  error: variable 'RemainingVTableCount' set but not used
  [-Werror,-Wunused-but-set-variable]

  llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp:306:23:
  error: private field 'PSI' is not used
  [-Werror,-Wunused-private-field]

Here are a couple of domino effects:

- Once I remove PSI, I need to update the contructor and its caller.

- Once I remove RemainingVTableCount, I don't need TotalCount, so I am
  updating the caller as well.

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 c9007498ee2331..fbed593ab3aa74 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -303,8 +303,6 @@ class IndirectCallPromoter {
   Function &F;
   Module &M;
 
-  ProfileSummaryInfo *PSI = nullptr;
-
   // Symtab that maps indirect call profile values to function names and
   // defines.
   InstrProfSymtab *const Symtab;
@@ -366,8 +364,7 @@ class IndirectCallPromoter {
 
   // Return true if it's profitable to compare vtables for the callsite.
   bool isProfitableToCompareVTables(const CallBase &CB,
-                                    ArrayRef<PromotionCandidate> Candidates,
-                                    uint64_t TotalCount);
+                                    ArrayRef<PromotionCandidate> Candidates);
 
   // Given an indirect callsite and the list of function candidates, compute
   // the following vtable information in output parameters and return vtable
@@ -391,12 +388,11 @@ class IndirectCallPromoter {
 
 public:
   IndirectCallPromoter(
-      Function &Func, Module &M, ProfileSummaryInfo *PSI,
-      InstrProfSymtab *Symtab, bool SamplePGO,
+      Function &Func, Module &M, InstrProfSymtab *Symtab, bool SamplePGO,
       const VirtualCallSiteTypeInfoMap &VirtualCSInfo,
       VTableAddressPointOffsetValMap &VTableAddressPointOffsetVal,
       OptimizationRemarkEmitter &ORE)
-      : F(Func), M(M), PSI(PSI), Symtab(Symtab), SamplePGO(SamplePGO),
+      : F(Func), M(M), Symtab(Symtab), SamplePGO(SamplePGO),
         VirtualCSInfo(VirtualCSInfo),
         VTableAddressPointOffsetVal(VTableAddressPointOffsetVal), ORE(ORE) {}
   IndirectCallPromoter(const IndirectCallPromoter &) = delete;
@@ -821,7 +817,7 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) {
     Instruction *VPtr =
         computeVTableInfos(CB, VTableGUIDCounts, PromotionCandidates);
 
-    if (isProfitableToCompareVTables(*CB, PromotionCandidates, TotalCount))
+    if (isProfitableToCompareVTables(*CB, PromotionCandidates))
       Changed |= tryToPromoteWithVTableCmp(*CB, VPtr, PromotionCandidates,
                                            TotalCount, NumCandidates,
                                            ICallProfDataRef, VTableGUIDCounts);
@@ -836,13 +832,11 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) {
 // TODO: Return false if the function addressing and vtable load instructions
 // cannot sink to indirect fallback.
 bool IndirectCallPromoter::isProfitableToCompareVTables(
-    const CallBase &CB, ArrayRef<PromotionCandidate> Candidates,
-    uint64_t TotalCount) {
+    const CallBase &CB, ArrayRef<PromotionCandidate> Candidates) {
   if (!EnableVTableProfileUse || Candidates.empty())
     return false;
   LLVM_DEBUG(dbgs() << "\nEvaluating vtable profitability for callsite #"
                     << NumOfPGOICallsites << CB << "\n");
-  uint64_t RemainingVTableCount = TotalCount;
   const size_t CandidateSize = Candidates.size();
   for (size_t I = 0; I < CandidateSize; I++) {
     auto &Candidate = Candidates[I];
@@ -868,8 +862,6 @@ bool IndirectCallPromoter::isProfitableToCompareVTables(
       return false;
     }
 
-    RemainingVTableCount -= Candidate.Count;
-
     // 'MaxNumVTable' limits the number of vtables to make vtable comparison
     // profitable. Comparing multiple vtables for one function candidate will
     // insert additional instructions on the hot path, and allowing more than
@@ -984,8 +976,7 @@ static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI, bool InLTO,
         MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
     auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
 
-    IndirectCallPromoter CallPromoter(F, M, PSI, &Symtab, SamplePGO,
-                                      VirtualCSInfo,
+    IndirectCallPromoter CallPromoter(F, M, &Symtab, SamplePGO, VirtualCSInfo,
                                       VTableAddressPointOffsetVal, ORE);
     bool FuncChanged = CallPromoter.processFunction(PSI);
     if (ICPDUMPAFTER && FuncChanged) {


        


More information about the llvm-commits mailing list