-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[IndirectCallPromotion] Use ArrayRef consistently (NFC) #96412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IndirectCallPromotion] Use ArrayRef consistently (NFC) #96412
Conversation
getPromotionCandidatesForCallSite uses const ArrayRef<InstrProfValueData> &, while tryToPromoteWithFuncCmp uses std::vector<PromotionCandidate> &. This patch switches to ArrayRef per LLVM Programmer’s Manual.
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-pgo Author: Kazu Hirata (kazutakahirata) ChangesgetPromotionCandidatesForCallSite uses const Full diff: https://github.com/llvm/llvm-project/pull/96412.diff 1 Files Affected:
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) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
getPromotionCandidatesForCallSite uses const
ArrayRef &, while tryToPromoteWithFuncCmp uses
std::vector &. This patch switches to ArrayRef
per LLVM Programmer’s Manual.