Skip to content

Commit 76b64ae

Browse files
[ProfileData] Migrate to a new version of getValueProfDataFromInst (llvm#95568)
Note that the version of getValueProfDataFromInst that returns bool has been "deprecated" since: commit 1e15371 Author: Mingming Liu <[email protected]> Date: Mon Apr 1 15:14:49 2024 -0700
1 parent 3d25e5a commit 76b64ae

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

llvm/unittests/ProfileData/InstrProfTest.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -941,12 +941,11 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
941941
Instruction *Inst2 = Builder.CreateCondBr(Builder.getTrue(), TBB, FBB);
942942
annotateValueSite(*M, *Inst, R.get(), IPVK_IndirectCallTarget, 0);
943943

944-
InstrProfValueData ValueData[5];
945944
uint32_t N;
946945
uint64_t T;
947-
bool Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5,
948-
ValueData, N, T);
949-
ASSERT_TRUE(Res);
946+
auto ValueData =
947+
getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
948+
ASSERT_NE(ValueData, nullptr);
950949
ASSERT_EQ(3U, N);
951950
ASSERT_EQ(21U, T);
952951
// The result should be sorted already:
@@ -956,23 +955,21 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
956955
ASSERT_EQ(5U, ValueData[1].Count);
957956
ASSERT_EQ(4000U, ValueData[2].Value);
958957
ASSERT_EQ(4U, ValueData[2].Count);
959-
Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 1, ValueData,
960-
N, T);
961-
ASSERT_TRUE(Res);
958+
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 1, N, T);
959+
ASSERT_NE(ValueData, nullptr);
962960
ASSERT_EQ(1U, N);
963961
ASSERT_EQ(21U, T);
964962

965-
Res = getValueProfDataFromInst(*Inst2, IPVK_IndirectCallTarget, 5, ValueData,
966-
N, T);
967-
ASSERT_FALSE(Res);
963+
ValueData =
964+
getValueProfDataFromInst(*Inst2, IPVK_IndirectCallTarget, 5, N, T);
965+
ASSERT_EQ(ValueData, nullptr);
968966

969967
// Remove the MD_prof metadata
970968
Inst->setMetadata(LLVMContext::MD_prof, 0);
971969
// Annotate 5 records this time.
972970
annotateValueSite(*M, *Inst, R.get(), IPVK_IndirectCallTarget, 0, 5);
973-
Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5,
974-
ValueData, N, T);
975-
ASSERT_TRUE(Res);
971+
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
972+
ASSERT_NE(ValueData, nullptr);
976973
ASSERT_EQ(5U, N);
977974
ASSERT_EQ(21U, T);
978975
ASSERT_EQ(6000U, ValueData[0].Value);
@@ -993,9 +990,8 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
993990
{5000, 2}, {6000, 1}};
994991
annotateValueSite(*M, *Inst, ArrayRef(VD0Sorted).slice(2), 10,
995992
IPVK_IndirectCallTarget, 5);
996-
Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5,
997-
ValueData, N, T);
998-
ASSERT_TRUE(Res);
993+
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
994+
ASSERT_NE(ValueData, nullptr);
999995
ASSERT_EQ(4U, N);
1000996
ASSERT_EQ(10U, T);
1001997
ASSERT_EQ(3000U, ValueData[0].Value);

0 commit comments

Comments
 (0)