[llvm] [IndirectCallPromotion] Use ArrayRef<PromotionCandidate> (NFC) (PR #97236)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 30 14:49:49 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

Aside from the fact that LLVM Programmer's Manual prefers ArrayRef to
const std::vector &, ArrayRef<PromotionCandidate> here makes it easier
to switch the underlying type to something like SmallVector.  Note
that we typically do not have a lot of candidates.


---
Full diff: https://github.com/llvm/llvm-project/pull/97236.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (+7-9) 


``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index d6c2d1f68751e..6a5aeeb8b52cc 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -359,16 +359,15 @@ class IndirectCallPromoter {
   // functions. Return true if there are IR transformations and false
   // otherwise.
   bool tryToPromoteWithVTableCmp(
-      CallBase &CB, Instruction *VPtr,
-      const std::vector<PromotionCandidate> &Candidates,
+      CallBase &CB, Instruction *VPtr, ArrayRef<PromotionCandidate> Candidates,
       uint64_t TotalFuncCount, uint32_t NumCandidates,
       MutableArrayRef<InstrProfValueData> ICallProfDataRef,
       VTableGUIDCountsMap &VTableGUIDCounts);
 
   // Return true if it's profitable to compare vtables for the callsite.
-  bool isProfitableToCompareVTables(
-      const CallBase &CB, const std::vector<PromotionCandidate> &Candidates,
-      uint64_t TotalCount);
+  bool isProfitableToCompareVTables(const CallBase &CB,
+                                    ArrayRef<PromotionCandidate> Candidates,
+                                    uint64_t TotalCount);
 
   // Given an indirect callsite and the list of function candidates, compute
   // the following vtable information in output parameters and return vtable
@@ -712,9 +711,8 @@ void IndirectCallPromoter::updateVPtrValueProfiles(
 }
 
 bool IndirectCallPromoter::tryToPromoteWithVTableCmp(
-    CallBase &CB, Instruction *VPtr,
-    const std::vector<PromotionCandidate> &Candidates, uint64_t TotalFuncCount,
-    uint32_t NumCandidates,
+    CallBase &CB, Instruction *VPtr, ArrayRef<PromotionCandidate> Candidates,
+    uint64_t TotalFuncCount, uint32_t NumCandidates,
     MutableArrayRef<InstrProfValueData> ICallProfDataRef,
     VTableGUIDCountsMap &VTableGUIDCounts) {
   SmallVector<uint64_t, 4> PromotedFuncCount;
@@ -839,7 +837,7 @@ 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, const std::vector<PromotionCandidate> &Candidates,
+    const CallBase &CB, ArrayRef<PromotionCandidate> Candidates,
     uint64_t TotalCount) {
   if (!EnableVTableProfileUse || Candidates.empty())
     return false;

``````````

</details>


https://github.com/llvm/llvm-project/pull/97236


More information about the llvm-commits mailing list