[llvm] [ProfileData] Drop an unused parameter from addValueData (PR #96233)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 18:20:05 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/96233
>From b30d44762da91f567330298553788a9f21450e39 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 20 Jun 2024 12:44:38 -0700
Subject: [PATCH 1/2] [ProfileData] Drop an unused parameter from addValueData
addValueData takes Site as a parameter but does not use it. This
patch drops the unused parameter and updates all the call sites.
---
llvm/include/llvm/ProfileData/InstrProf.h | 3 +-
llvm/lib/ProfileData/InstrProf.cpp | 4 +-
llvm/lib/ProfileData/InstrProfReader.cpp | 2 +-
llvm/unittests/ProfileData/InstrProfTest.cpp | 78 ++++++++++----------
4 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index df79073da5b50..32b1ce055097d 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -861,8 +861,7 @@ struct InstrProfRecord {
inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
/// Add ValueData for ValueKind at value Site.
- void addValueData(uint32_t ValueKind, uint32_t Site,
- InstrProfValueData *VData, uint32_t N,
+ void addValueData(uint32_t ValueKind, InstrProfValueData *VData, uint32_t N,
InstrProfSymtab *SymTab);
/// Merge the counts in \p Other into this one.
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 8cc1625e1c05c..d2b7ff0d210db 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -993,7 +993,7 @@ uint64_t InstrProfRecord::remapValue(uint64_t Value, uint32_t ValueKind,
return Value;
}
-void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
+void InstrProfRecord::addValueData(uint32_t ValueKind,
InstrProfValueData *VData, uint32_t N,
InstrProfSymtab *ValueMap) {
for (uint32_t I = 0; I < N; I++) {
@@ -1138,7 +1138,7 @@ void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfValueData *ValueData = getValueProfRecordValueData(this);
for (uint64_t VSite = 0; VSite < NumValueSites; ++VSite) {
uint8_t ValueDataCount = this->SiteCountArray[VSite];
- Record.addValueData(Kind, VSite, ValueData, ValueDataCount, SymTab);
+ Record.addValueData(Kind, ValueData, ValueDataCount, SymTab);
ValueData += ValueDataCount;
}
}
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index e18ce5d373d1c..f94fa63694747 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -378,7 +378,7 @@ TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) {
CurrentValues.push_back({Value, TakenCount});
Line++;
}
- Record.addValueData(ValueKind, S, CurrentValues.data(), NumValueData,
+ Record.addValueData(ValueKind, CurrentValues.data(), NumValueData,
nullptr);
}
}
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index e39da6b33ecf2..970de74bc49b5 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -808,13 +808,13 @@ TEST_P(InstrProfReaderWriterTest, icall_and_vtable_data_read_write) {
Record1.reserveSites(IPVK_IndirectCallTarget, 4);
InstrProfValueData VD0[] = {
{(uint64_t)callee1, 1}, {(uint64_t)callee2, 2}, {(uint64_t)callee3, 3}};
- Record1.addValueData(IPVK_IndirectCallTarget, 0, VD0, 3, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, VD0, 3, nullptr);
// No value profile data at the second site.
- Record1.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
InstrProfValueData VD2[] = {{(uint64_t)callee1, 1}, {(uint64_t)callee2, 2}};
- Record1.addValueData(IPVK_IndirectCallTarget, 2, VD2, 2, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, VD2, 2, nullptr);
InstrProfValueData VD3[] = {{(uint64_t)callee7, 1}, {(uint64_t)callee8, 2}};
- Record1.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
}
// 2 vtable value sites.
@@ -828,8 +828,8 @@ TEST_P(InstrProfReaderWriterTest, icall_and_vtable_data_read_write) {
{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
};
- Record1.addValueData(IPVK_VTableTarget, 0, VD0, 3, nullptr);
- Record1.addValueData(IPVK_VTableTarget, 2, VD2, 2, nullptr);
+ Record1.addValueData(IPVK_VTableTarget, VD0, 3, nullptr);
+ Record1.addValueData(IPVK_VTableTarget, VD2, 2, nullptr);
}
Writer.addRecord(std::move(Record1), getProfWeight(), Err);
@@ -918,7 +918,7 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
Record.reserveSites(IPVK_IndirectCallTarget, 1);
InstrProfValueData VD0[] = {{1000, 1}, {2000, 2}, {3000, 3}, {5000, 5},
{4000, 4}, {6000, 6}};
- Record.addValueData(IPVK_IndirectCallTarget, 0, VD0, 6, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD0, 6, nullptr);
Writer.addRecord(std::move(Record), Err);
auto Profile = Writer.writeBuffer();
readProfile(std::move(Profile));
@@ -1017,21 +1017,21 @@ TEST_P(MaybeSparseInstrProfTest, icall_and_vtable_data_merge) {
{uint64_t(callee2), 2},
{uint64_t(callee3), 3},
{uint64_t(callee4), 4}};
- Record11.addValueData(IPVK_IndirectCallTarget, 0, VD0, 4, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, VD0, 4, nullptr);
// No value profile data at the second site.
- Record11.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
InstrProfValueData VD2[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record11.addValueData(IPVK_IndirectCallTarget, 2, VD2, 3, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, VD2, 3, nullptr);
InstrProfValueData VD3[] = {{uint64_t(callee7), 1}, {uint64_t(callee8), 2}};
- Record11.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
InstrProfValueData VD4[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record11.addValueData(IPVK_IndirectCallTarget, 4, VD4, 3, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, VD4, 3, nullptr);
}
// 3 value sites for vtables.
{
@@ -1040,53 +1040,53 @@ TEST_P(MaybeSparseInstrProfTest, icall_and_vtable_data_merge) {
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3},
{getCalleeAddress(vtable4), 4}};
- Record11.addValueData(IPVK_VTableTarget, 0, VD0, 4, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, VD0, 4, nullptr);
InstrProfValueData VD2[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record11.addValueData(IPVK_VTableTarget, 1, VD2, 3, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
InstrProfValueData VD4[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record11.addValueData(IPVK_VTableTarget, 3, VD4, 3, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, VD4, 3, nullptr);
}
// A different record for the same caller.
Record12.reserveSites(IPVK_IndirectCallTarget, 5);
InstrProfValueData VD02[] = {{uint64_t(callee2), 5}, {uint64_t(callee3), 3}};
- Record12.addValueData(IPVK_IndirectCallTarget, 0, VD02, 2, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, VD02, 2, nullptr);
// No value profile data at the second site.
- Record12.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
InstrProfValueData VD22[] = {
{uint64_t(callee2), 1}, {uint64_t(callee3), 3}, {uint64_t(callee4), 4}};
- Record12.addValueData(IPVK_IndirectCallTarget, 2, VD22, 3, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, VD22, 3, nullptr);
- Record12.addValueData(IPVK_IndirectCallTarget, 3, nullptr, 0, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
InstrProfValueData VD42[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record12.addValueData(IPVK_IndirectCallTarget, 4, VD42, 3, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, VD42, 3, nullptr);
// 3 value sites for vtables.
{
Record12.reserveSites(IPVK_VTableTarget, 3);
InstrProfValueData VD0[] = {{getCalleeAddress(vtable2), 5},
{getCalleeAddress(vtable3), 3}};
- Record12.addValueData(IPVK_VTableTarget, 0, VD0, 2, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, VD0, 2, nullptr);
InstrProfValueData VD2[] = {{getCalleeAddress(vtable2), 1},
{getCalleeAddress(vtable3), 3},
{getCalleeAddress(vtable4), 4}};
- Record12.addValueData(IPVK_VTableTarget, 1, VD2, 3, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
InstrProfValueData VD4[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record12.addValueData(IPVK_VTableTarget, 3, VD4, 3, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, VD4, 3, nullptr);
}
Writer.addRecord(std::move(Record11), Err);
@@ -1226,7 +1226,7 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_saturation) {
NamedInstrProfRecord Record4("baz", 0x5678, {3, 4});
Record4.reserveSites(ValueKind, 1);
InstrProfValueData VD4[] = {{ProfiledValue, 1}};
- Record4.addValueData(ValueKind, 0, VD4, 1, nullptr);
+ Record4.addValueData(ValueKind, VD4, 1, nullptr);
Result = instrprof_error::success;
Writer.addRecord(std::move(Record4), Err);
ASSERT_EQ(Result, instrprof_error::success);
@@ -1235,7 +1235,7 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_saturation) {
NamedInstrProfRecord Record5("baz", 0x5678, {5, 6});
Record5.reserveSites(ValueKind, 1);
InstrProfValueData VD5[] = {{ProfiledValue, MaxValCount}};
- Record5.addValueData(ValueKind, 0, VD5, 1, nullptr);
+ Record5.addValueData(ValueKind, VD5, 1, nullptr);
Result = instrprof_error::success;
Writer.addRecord(std::move(Record5), Err);
ASSERT_EQ(Result, instrprof_error::counter_overflow);
@@ -1275,8 +1275,8 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_site_trunc) {
VD0[I].Count = 2 * I + 1000;
}
- Record11.addValueData(ValueKind, 0, VD0, 255, nullptr);
- Record11.addValueData(ValueKind, 1, nullptr, 0, nullptr);
+ Record11.addValueData(ValueKind, VD0, 255, nullptr);
+ Record11.addValueData(ValueKind, nullptr, 0, nullptr);
Record12.reserveSites(ValueKind, 2);
InstrProfValueData VD1[255];
@@ -1285,8 +1285,8 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_site_trunc) {
VD1[I].Count = 2 * I + 1001;
}
- Record12.addValueData(ValueKind, 0, VD1, 255, nullptr);
- Record12.addValueData(ValueKind, 1, nullptr, 0, nullptr);
+ Record12.addValueData(ValueKind, VD1, 255, nullptr);
+ Record12.addValueData(ValueKind, nullptr, 0, nullptr);
Writer.addRecord(std::move(Record11), Err);
// Merge profile data.
@@ -1323,23 +1323,23 @@ static void addValueProfData(InstrProfRecord &Record) {
{uint64_t(callee3), 500},
{uint64_t(callee4), 300},
{uint64_t(callee5), 100}};
- Record.addValueData(IPVK_IndirectCallTarget, 0, VD0, 5, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD0, 5, nullptr);
InstrProfValueData VD1[] = {{uint64_t(callee5), 800},
{uint64_t(callee3), 1000},
{uint64_t(callee2), 2500},
{uint64_t(callee1), 1300}};
- Record.addValueData(IPVK_IndirectCallTarget, 1, VD1, 4, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD1, 4, nullptr);
InstrProfValueData VD2[] = {{uint64_t(callee6), 800},
{uint64_t(callee3), 1000},
{uint64_t(callee4), 5500}};
- Record.addValueData(IPVK_IndirectCallTarget, 2, VD2, 3, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD2, 3, nullptr);
InstrProfValueData VD3[] = {{uint64_t(callee2), 1800},
{uint64_t(callee3), 2000}};
- Record.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
- Record.addValueData(IPVK_IndirectCallTarget, 4, nullptr, 0, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
InstrProfValueData VD5[] = {{uint64_t(callee7), 1234},
{uint64_t(callee8), 5678}};
- Record.addValueData(IPVK_IndirectCallTarget, 5, VD5, 2, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, VD5, 2, nullptr);
}
// Add test data for vtables
@@ -1361,10 +1361,10 @@ static void addValueProfData(InstrProfRecord &Record) {
};
InstrProfValueData VD3[] = {{getCalleeAddress(vtable2), 1800},
{getCalleeAddress(vtable3), 2000}};
- Record.addValueData(IPVK_VTableTarget, 0, VD0, 5, nullptr);
- Record.addValueData(IPVK_VTableTarget, 1, VD1, 4, nullptr);
- Record.addValueData(IPVK_VTableTarget, 2, VD2, 3, nullptr);
- Record.addValueData(IPVK_VTableTarget, 3, VD3, 2, nullptr);
+ Record.addValueData(IPVK_VTableTarget, VD0, 5, nullptr);
+ Record.addValueData(IPVK_VTableTarget, VD1, 4, nullptr);
+ Record.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
+ Record.addValueData(IPVK_VTableTarget, VD3, 2, nullptr);
}
}
>From 40e5302c504dc0e15edc86f896c1fab48f26c4e3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 20 Jun 2024 18:19:10 -0700
Subject: [PATCH 2/2] Add an assert instead.
---
llvm/include/llvm/ProfileData/InstrProf.h | 6 +-
llvm/lib/ProfileData/InstrProf.cpp | 5 +-
llvm/lib/ProfileData/InstrProfReader.cpp | 2 +-
llvm/unittests/ProfileData/InstrProfTest.cpp | 78 ++++++++++----------
4 files changed, 47 insertions(+), 44 deletions(-)
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 32b1ce055097d..d5ddf16957c83 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -860,8 +860,10 @@ struct InstrProfRecord {
/// Reserve space for NumValueSites sites.
inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
- /// Add ValueData for ValueKind at value Site.
- void addValueData(uint32_t ValueKind, InstrProfValueData *VData, uint32_t N,
+ /// Add ValueData for ValueKind at value Site. We do not support adding sites
+ /// out of order. Site must go up from 0 one by one.
+ void addValueData(uint32_t ValueKind, uint32_t Site,
+ InstrProfValueData *VData, uint32_t N,
InstrProfSymtab *SymTab);
/// Merge the counts in \p Other into this one.
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index d2b7ff0d210db..3e0e2b2284d8f 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -993,7 +993,7 @@ uint64_t InstrProfRecord::remapValue(uint64_t Value, uint32_t ValueKind,
return Value;
}
-void InstrProfRecord::addValueData(uint32_t ValueKind,
+void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
InstrProfValueData *VData, uint32_t N,
InstrProfSymtab *ValueMap) {
for (uint32_t I = 0; I < N; I++) {
@@ -1001,6 +1001,7 @@ void InstrProfRecord::addValueData(uint32_t ValueKind,
}
std::vector<InstrProfValueSiteRecord> &ValueSites =
getOrCreateValueSitesForKind(ValueKind);
+ assert(ValueSites.size() == Site);
if (N == 0)
ValueSites.emplace_back();
else
@@ -1138,7 +1139,7 @@ void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfValueData *ValueData = getValueProfRecordValueData(this);
for (uint64_t VSite = 0; VSite < NumValueSites; ++VSite) {
uint8_t ValueDataCount = this->SiteCountArray[VSite];
- Record.addValueData(Kind, ValueData, ValueDataCount, SymTab);
+ Record.addValueData(Kind, VSite, ValueData, ValueDataCount, SymTab);
ValueData += ValueDataCount;
}
}
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index f94fa63694747..e18ce5d373d1c 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -378,7 +378,7 @@ TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) {
CurrentValues.push_back({Value, TakenCount});
Line++;
}
- Record.addValueData(ValueKind, CurrentValues.data(), NumValueData,
+ Record.addValueData(ValueKind, S, CurrentValues.data(), NumValueData,
nullptr);
}
}
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 970de74bc49b5..a2cda2ba52dfe 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -808,13 +808,13 @@ TEST_P(InstrProfReaderWriterTest, icall_and_vtable_data_read_write) {
Record1.reserveSites(IPVK_IndirectCallTarget, 4);
InstrProfValueData VD0[] = {
{(uint64_t)callee1, 1}, {(uint64_t)callee2, 2}, {(uint64_t)callee3, 3}};
- Record1.addValueData(IPVK_IndirectCallTarget, VD0, 3, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, 0, VD0, 3, nullptr);
// No value profile data at the second site.
- Record1.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
InstrProfValueData VD2[] = {{(uint64_t)callee1, 1}, {(uint64_t)callee2, 2}};
- Record1.addValueData(IPVK_IndirectCallTarget, VD2, 2, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, 2, VD2, 2, nullptr);
InstrProfValueData VD3[] = {{(uint64_t)callee7, 1}, {(uint64_t)callee8, 2}};
- Record1.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
+ Record1.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
}
// 2 vtable value sites.
@@ -828,8 +828,8 @@ TEST_P(InstrProfReaderWriterTest, icall_and_vtable_data_read_write) {
{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
};
- Record1.addValueData(IPVK_VTableTarget, VD0, 3, nullptr);
- Record1.addValueData(IPVK_VTableTarget, VD2, 2, nullptr);
+ Record1.addValueData(IPVK_VTableTarget, 0, VD0, 3, nullptr);
+ Record1.addValueData(IPVK_VTableTarget, 1, VD2, 2, nullptr);
}
Writer.addRecord(std::move(Record1), getProfWeight(), Err);
@@ -918,7 +918,7 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
Record.reserveSites(IPVK_IndirectCallTarget, 1);
InstrProfValueData VD0[] = {{1000, 1}, {2000, 2}, {3000, 3}, {5000, 5},
{4000, 4}, {6000, 6}};
- Record.addValueData(IPVK_IndirectCallTarget, VD0, 6, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 0, VD0, 6, nullptr);
Writer.addRecord(std::move(Record), Err);
auto Profile = Writer.writeBuffer();
readProfile(std::move(Profile));
@@ -1017,21 +1017,21 @@ TEST_P(MaybeSparseInstrProfTest, icall_and_vtable_data_merge) {
{uint64_t(callee2), 2},
{uint64_t(callee3), 3},
{uint64_t(callee4), 4}};
- Record11.addValueData(IPVK_IndirectCallTarget, VD0, 4, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, 0, VD0, 4, nullptr);
// No value profile data at the second site.
- Record11.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
InstrProfValueData VD2[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record11.addValueData(IPVK_IndirectCallTarget, VD2, 3, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, 2, VD2, 3, nullptr);
InstrProfValueData VD3[] = {{uint64_t(callee7), 1}, {uint64_t(callee8), 2}};
- Record11.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
InstrProfValueData VD4[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record11.addValueData(IPVK_IndirectCallTarget, VD4, 3, nullptr);
+ Record11.addValueData(IPVK_IndirectCallTarget, 4, VD4, 3, nullptr);
}
// 3 value sites for vtables.
{
@@ -1040,53 +1040,53 @@ TEST_P(MaybeSparseInstrProfTest, icall_and_vtable_data_merge) {
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3},
{getCalleeAddress(vtable4), 4}};
- Record11.addValueData(IPVK_VTableTarget, VD0, 4, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, 0, VD0, 4, nullptr);
InstrProfValueData VD2[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record11.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, 1, VD2, 3, nullptr);
InstrProfValueData VD4[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record11.addValueData(IPVK_VTableTarget, VD4, 3, nullptr);
+ Record11.addValueData(IPVK_VTableTarget, 2, VD4, 3, nullptr);
}
// A different record for the same caller.
Record12.reserveSites(IPVK_IndirectCallTarget, 5);
InstrProfValueData VD02[] = {{uint64_t(callee2), 5}, {uint64_t(callee3), 3}};
- Record12.addValueData(IPVK_IndirectCallTarget, VD02, 2, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, 0, VD02, 2, nullptr);
// No value profile data at the second site.
- Record12.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
InstrProfValueData VD22[] = {
{uint64_t(callee2), 1}, {uint64_t(callee3), 3}, {uint64_t(callee4), 4}};
- Record12.addValueData(IPVK_IndirectCallTarget, VD22, 3, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, 2, VD22, 3, nullptr);
- Record12.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, 3, nullptr, 0, nullptr);
InstrProfValueData VD42[] = {
{uint64_t(callee1), 1}, {uint64_t(callee2), 2}, {uint64_t(callee3), 3}};
- Record12.addValueData(IPVK_IndirectCallTarget, VD42, 3, nullptr);
+ Record12.addValueData(IPVK_IndirectCallTarget, 4, VD42, 3, nullptr);
// 3 value sites for vtables.
{
Record12.reserveSites(IPVK_VTableTarget, 3);
InstrProfValueData VD0[] = {{getCalleeAddress(vtable2), 5},
{getCalleeAddress(vtable3), 3}};
- Record12.addValueData(IPVK_VTableTarget, VD0, 2, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, 0, VD0, 2, nullptr);
InstrProfValueData VD2[] = {{getCalleeAddress(vtable2), 1},
{getCalleeAddress(vtable3), 3},
{getCalleeAddress(vtable4), 4}};
- Record12.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, 1, VD2, 3, nullptr);
InstrProfValueData VD4[] = {{getCalleeAddress(vtable1), 1},
{getCalleeAddress(vtable2), 2},
{getCalleeAddress(vtable3), 3}};
- Record12.addValueData(IPVK_VTableTarget, VD4, 3, nullptr);
+ Record12.addValueData(IPVK_VTableTarget, 2, VD4, 3, nullptr);
}
Writer.addRecord(std::move(Record11), Err);
@@ -1226,7 +1226,7 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_saturation) {
NamedInstrProfRecord Record4("baz", 0x5678, {3, 4});
Record4.reserveSites(ValueKind, 1);
InstrProfValueData VD4[] = {{ProfiledValue, 1}};
- Record4.addValueData(ValueKind, VD4, 1, nullptr);
+ Record4.addValueData(ValueKind, 0, VD4, 1, nullptr);
Result = instrprof_error::success;
Writer.addRecord(std::move(Record4), Err);
ASSERT_EQ(Result, instrprof_error::success);
@@ -1235,7 +1235,7 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_saturation) {
NamedInstrProfRecord Record5("baz", 0x5678, {5, 6});
Record5.reserveSites(ValueKind, 1);
InstrProfValueData VD5[] = {{ProfiledValue, MaxValCount}};
- Record5.addValueData(ValueKind, VD5, 1, nullptr);
+ Record5.addValueData(ValueKind, 0, VD5, 1, nullptr);
Result = instrprof_error::success;
Writer.addRecord(std::move(Record5), Err);
ASSERT_EQ(Result, instrprof_error::counter_overflow);
@@ -1275,8 +1275,8 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_site_trunc) {
VD0[I].Count = 2 * I + 1000;
}
- Record11.addValueData(ValueKind, VD0, 255, nullptr);
- Record11.addValueData(ValueKind, nullptr, 0, nullptr);
+ Record11.addValueData(ValueKind, 0, VD0, 255, nullptr);
+ Record11.addValueData(ValueKind, 1, nullptr, 0, nullptr);
Record12.reserveSites(ValueKind, 2);
InstrProfValueData VD1[255];
@@ -1285,8 +1285,8 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_site_trunc) {
VD1[I].Count = 2 * I + 1001;
}
- Record12.addValueData(ValueKind, VD1, 255, nullptr);
- Record12.addValueData(ValueKind, nullptr, 0, nullptr);
+ Record12.addValueData(ValueKind, 0, VD1, 255, nullptr);
+ Record12.addValueData(ValueKind, 1, nullptr, 0, nullptr);
Writer.addRecord(std::move(Record11), Err);
// Merge profile data.
@@ -1323,23 +1323,23 @@ static void addValueProfData(InstrProfRecord &Record) {
{uint64_t(callee3), 500},
{uint64_t(callee4), 300},
{uint64_t(callee5), 100}};
- Record.addValueData(IPVK_IndirectCallTarget, VD0, 5, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 0, VD0, 5, nullptr);
InstrProfValueData VD1[] = {{uint64_t(callee5), 800},
{uint64_t(callee3), 1000},
{uint64_t(callee2), 2500},
{uint64_t(callee1), 1300}};
- Record.addValueData(IPVK_IndirectCallTarget, VD1, 4, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 1, VD1, 4, nullptr);
InstrProfValueData VD2[] = {{uint64_t(callee6), 800},
{uint64_t(callee3), 1000},
{uint64_t(callee4), 5500}};
- Record.addValueData(IPVK_IndirectCallTarget, VD2, 3, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 2, VD2, 3, nullptr);
InstrProfValueData VD3[] = {{uint64_t(callee2), 1800},
{uint64_t(callee3), 2000}};
- Record.addValueData(IPVK_IndirectCallTarget, VD3, 2, nullptr);
- Record.addValueData(IPVK_IndirectCallTarget, nullptr, 0, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 3, VD3, 2, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 4, nullptr, 0, nullptr);
InstrProfValueData VD5[] = {{uint64_t(callee7), 1234},
{uint64_t(callee8), 5678}};
- Record.addValueData(IPVK_IndirectCallTarget, VD5, 2, nullptr);
+ Record.addValueData(IPVK_IndirectCallTarget, 5, VD5, 2, nullptr);
}
// Add test data for vtables
@@ -1361,10 +1361,10 @@ static void addValueProfData(InstrProfRecord &Record) {
};
InstrProfValueData VD3[] = {{getCalleeAddress(vtable2), 1800},
{getCalleeAddress(vtable3), 2000}};
- Record.addValueData(IPVK_VTableTarget, VD0, 5, nullptr);
- Record.addValueData(IPVK_VTableTarget, VD1, 4, nullptr);
- Record.addValueData(IPVK_VTableTarget, VD2, 3, nullptr);
- Record.addValueData(IPVK_VTableTarget, VD3, 2, nullptr);
+ Record.addValueData(IPVK_VTableTarget, 0, VD0, 5, nullptr);
+ Record.addValueData(IPVK_VTableTarget, 1, VD1, 4, nullptr);
+ Record.addValueData(IPVK_VTableTarget, 2, VD2, 3, nullptr);
+ Record.addValueData(IPVK_VTableTarget, 3, VD3, 2, nullptr);
}
}
More information about the llvm-commits
mailing list