diff options
author | Kazu Hirata <kazu@google.com> | 2024-06-22 00:40:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-22 00:40:36 -0700 |
commit | b0ae923ada836fa2c9114ac2c5afb39466f49fe0 (patch) | |
tree | 612042464b9280b9e5004e59732d3ea164d23c7e /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | 75006466296ed4b0f845cbbec4bf77c21de43b40 (diff) | |
download | llvm-b0ae923ada836fa2c9114ac2c5afb39466f49fe0.zip llvm-b0ae923ada836fa2c9114ac2c5afb39466f49fe0.tar.gz llvm-b0ae923ada836fa2c9114ac2c5afb39466f49fe0.tar.bz2 |
[ProfileData] Add a variant of getValueProfDataFromInst (#95993)
This patch adds a variant of getValueProfDataFromInst that returns
std::vector<InstrProfValueData> instead of
std::unique<InstrProfValueData[]>. The new return type carries the
length with it, so we can drop out parameter ActualNumValueData.
Also, the caller can directly feed the return value into a range-based
for loop as shown in the patch.
I'm planning to migrate other callers of getValueProfDataFromInst to
the new variant in follow-up patches.
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index c6934f5..94ac048 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -143,20 +143,15 @@ static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser, const Instruction *I = dyn_cast<Instruction>(CurUser); if (I) { - uint32_t ActualNumValueData = 0; uint64_t TotalCount = 0; // MaxNumVTableAnnotations is the maximum number of vtables annotated on // the instruction. - auto ValueDataArray = - getValueProfDataFromInst(*I, IPVK_VTableTarget, MaxNumVTableAnnotations, - ActualNumValueData, TotalCount); - - if (ValueDataArray.get()) { - for (uint32_t j = 0; j < ActualNumValueData; j++) { - RefEdges.insert(Index.getOrInsertValueInfo(/* VTableGUID = */ - ValueDataArray[j].Value)); - } - } + auto ValueDataArray = getValueProfDataFromInst( + *I, IPVK_VTableTarget, MaxNumVTableAnnotations, TotalCount); + + for (const auto &V : ValueDataArray) + RefEdges.insert(Index.getOrInsertValueInfo(/* VTableGUID = */ + V.Value)); } return HasBlockAddress; } |