[llvm] [IndirectCallPromotion] Use ArrayRef<PromotionCandidate> (NFC) (PR #97236)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 30 14:49:21 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97236
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.
>From 3842ac8e4f896ff518ee79e3760df8de8767d751 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 30 Jun 2024 14:35:15 -0700
Subject: [PATCH] [IndirectCallPromotion] Use ArrayRef<PromotionCandidate>
(NFC)
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.
---
.../Instrumentation/IndirectCallPromotion.cpp | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
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;
More information about the llvm-commits
mailing list