Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

getPromotionCandidatesForCallSite uses const
ArrayRef &, while tryToPromoteWithFuncCmp uses
std::vector &. This patch switches to ArrayRef
per LLVM Programmer’s Manual.

getPromotionCandidatesForCallSite uses const
ArrayRef<InstrProfValueData> &, while tryToPromoteWithFuncCmp uses
std::vector<PromotionCandidate> &.  This patch switches to ArrayRef
per LLVM Programmer’s Manual.
@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels Jun 23, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 23, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

getPromotionCandidatesForCallSite uses const
ArrayRef<InstrProfValueData> &, while tryToPromoteWithFuncCmp uses
std::vector<PromotionCandidate> &. This patch switches to ArrayRef
per LLVM Programmer’s Manual.


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (+9-9)
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index bb8019b5c31d8..fe9eaae9ac7ea 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -133,16 +133,17 @@ class IndirectCallPromoter {
   // TotalCount is the total profiled count of call executions, and
   // NumCandidates is the number of candidate entries in ValueDataRef.
   std::vector<PromotionCandidate> getPromotionCandidatesForCallSite(
-      const CallBase &CB, const ArrayRef<InstrProfValueData> &ValueDataRef,
+      const CallBase &CB, ArrayRef<InstrProfValueData> ValueDataRef,
       uint64_t TotalCount, uint32_t NumCandidates);
 
   // Promote a list of targets for one indirect-call callsite by comparing
   // indirect callee with functions. Returns true if there are IR
   // transformations and false otherwise.
-  bool tryToPromoteWithFuncCmp(
-      CallBase &CB, const std::vector<PromotionCandidate> &Candidates,
-      uint64_t TotalCount, ArrayRef<InstrProfValueData> ICallProfDataRef,
-      uint32_t NumCandidates);
+  bool tryToPromoteWithFuncCmp(CallBase &CB,
+                               ArrayRef<PromotionCandidate> Candidates,
+                               uint64_t TotalCount,
+                               ArrayRef<InstrProfValueData> ICallProfDataRef,
+                               uint32_t NumCandidates);
 
 public:
   IndirectCallPromoter(Function &Func, InstrProfSymtab *Symtab, bool SamplePGO,
@@ -160,7 +161,7 @@ class IndirectCallPromoter {
 // the count. Stop at the first target that is not promoted.
 std::vector<IndirectCallPromoter::PromotionCandidate>
 IndirectCallPromoter::getPromotionCandidatesForCallSite(
-    const CallBase &CB, const ArrayRef<InstrProfValueData> &ValueDataRef,
+    const CallBase &CB, ArrayRef<InstrProfValueData> ValueDataRef,
     uint64_t TotalCount, uint32_t NumCandidates) {
   std::vector<PromotionCandidate> Ret;
 
@@ -277,9 +278,8 @@ CallBase &llvm::pgo::promoteIndirectCall(CallBase &CB, Function *DirectCallee,
 
 // Promote indirect-call to conditional direct-call for one callsite.
 bool IndirectCallPromoter::tryToPromoteWithFuncCmp(
-    CallBase &CB, const std::vector<PromotionCandidate> &Candidates,
-    uint64_t TotalCount, ArrayRef<InstrProfValueData> ICallProfDataRef,
-    uint32_t NumCandidates) {
+    CallBase &CB, ArrayRef<PromotionCandidate> Candidates, uint64_t TotalCount,
+    ArrayRef<InstrProfValueData> ICallProfDataRef, uint32_t NumCandidates) {
   uint32_t NumPromoted = 0;
 
   for (const auto &C : Candidates) {

Copy link
Collaborator

@dwblaikie dwblaikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mingmingl-llvm mingmingl-llvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should really check the PRs that need my attention.

@kazutakahirata kazutakahirata merged commit c44e9ff into llvm:main Jun 28, 2024
@kazutakahirata kazutakahirata deleted the cleanup_IndirectCallPromotion_ArrayRef branch June 28, 2024 19:32
cpiaseque pushed a commit to cpiaseque/llvm-project that referenced this pull request Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:transforms PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants