[llvm] [Transforms] Migrate to a new version of getValueProfDataFromInst (PR #95485)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 16:46:23 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/95485
Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:
commit 1e15371dd8843dfc52b9435afaa133997c1773d8
Author: Mingming Liu <mingmingl at google.com>
Date: Mon Apr 1 15:14:49 2024 -0700
>From 76bcb9151a54f423621bd9d807398e19d5c9824e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 13 Jun 2024 16:20:18 -0700
Subject: [PATCH] [Transforms] Migrate to a new version of
getValueProfDataFromInst
Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:
commit 1e15371dd8843dfc52b9435afaa133997c1773d8
Author: Mingming Liu <mingmingl at google.com>
Date: Mon Apr 1 15:14:49 2024 -0700
---
llvm/lib/Transforms/IPO/SampleProfile.cpp | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 7e6a8817b7a67..61078c4194b81 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -790,14 +790,12 @@ SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
static bool doesHistoryAllowICP(const Instruction &Inst, StringRef Candidate) {
uint32_t NumVals = 0;
uint64_t TotalCount = 0;
- std::unique_ptr<InstrProfValueData[]> ValueData =
- std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
- bool Valid =
+ auto ValueData =
getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
- ValueData.get(), NumVals, TotalCount, true);
+ NumVals, TotalCount, true);
// No valid value profile so no promoted targets have been recorded
// before. Ok to do ICP.
- if (!Valid)
+ if (!ValueData)
return true;
unsigned NumPromoted = 0;
@@ -837,11 +835,8 @@ updateIDTMetaData(Instruction &Inst,
uint32_t NumVals = 0;
// OldSum is the existing total count in the value profile data.
uint64_t OldSum = 0;
- std::unique_ptr<InstrProfValueData[]> ValueData =
- std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
- bool Valid =
- getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
- ValueData.get(), NumVals, OldSum, true);
+ auto ValueData = getValueProfDataFromInst(
+ Inst, IPVK_IndirectCallTarget, MaxNumPromotions, NumVals, OldSum, true);
DenseMap<uint64_t, uint64_t> ValueCountMap;
if (Sum == 0) {
@@ -850,7 +845,7 @@ updateIDTMetaData(Instruction &Inst,
"If sum is 0, assume only one element in CallTargets "
"with count being NOMORE_ICP_MAGICNUM");
// Initialize ValueCountMap with existing value profile data.
- if (Valid) {
+ if (ValueData) {
for (uint32_t I = 0; I < NumVals; I++)
ValueCountMap[ValueData[I].Value] = ValueData[I].Count;
}
@@ -866,7 +861,7 @@ updateIDTMetaData(Instruction &Inst,
} else {
// Initialize ValueCountMap with existing NOMORE_ICP_MAGICNUM
// counts in the value profile.
- if (Valid) {
+ if (ValueData) {
for (uint32_t I = 0; I < NumVals; I++) {
if (ValueData[I].Count == NOMORE_ICP_MAGICNUM)
ValueCountMap[ValueData[I].Value] = ValueData[I].Count;
More information about the llvm-commits
mailing list