Skip to content

[ProfileData] Migrate to a new version of getValueProfDataFromInst #96381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions llvm/unittests/ProfileData/InstrProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,10 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
Instruction *Inst2 = Builder.CreateCondBr(Builder.getTrue(), TBB, FBB);
annotateValueSite(*M, *Inst, R.get(), IPVK_IndirectCallTarget, 0);

uint32_t N;
uint64_t T;
auto ValueData =
getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
ASSERT_NE(ValueData, nullptr);
ASSERT_EQ(3U, N);
getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, T);
ASSERT_THAT(ValueData, SizeIs(3));
ASSERT_EQ(21U, T);
// The result should be sorted already:
ASSERT_EQ(6000U, ValueData[0].Value);
Expand All @@ -956,22 +954,19 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
ASSERT_EQ(5U, ValueData[1].Count);
ASSERT_EQ(4000U, ValueData[2].Value);
ASSERT_EQ(4U, ValueData[2].Count);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 1, N, T);
ASSERT_NE(ValueData, nullptr);
ASSERT_EQ(1U, N);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 1, T);
ASSERT_THAT(ValueData, SizeIs(1));
ASSERT_EQ(21U, T);

ValueData =
getValueProfDataFromInst(*Inst2, IPVK_IndirectCallTarget, 5, N, T);
ASSERT_EQ(ValueData, nullptr);
ValueData = getValueProfDataFromInst(*Inst2, IPVK_IndirectCallTarget, 5, T);
ASSERT_THAT(ValueData, SizeIs(0));

// Remove the MD_prof metadata
Inst->setMetadata(LLVMContext::MD_prof, 0);
// Annotate 5 records this time.
annotateValueSite(*M, *Inst, R.get(), IPVK_IndirectCallTarget, 0, 5);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
ASSERT_NE(ValueData, nullptr);
ASSERT_EQ(5U, N);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, T);
ASSERT_THAT(ValueData, SizeIs(5));
ASSERT_EQ(21U, T);
ASSERT_EQ(6000U, ValueData[0].Value);
ASSERT_EQ(6U, ValueData[0].Count);
Expand All @@ -991,9 +986,8 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
{5000, 2}, {6000, 1}};
annotateValueSite(*M, *Inst, ArrayRef(VD0Sorted).slice(2), 10,
IPVK_IndirectCallTarget, 5);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, N, T);
ASSERT_NE(ValueData, nullptr);
ASSERT_EQ(4U, N);
ValueData = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5, T);
ASSERT_THAT(ValueData, SizeIs(4));
ASSERT_EQ(10U, T);
ASSERT_EQ(3000U, ValueData[0].Value);
ASSERT_EQ(4U, ValueData[0].Count);
Expand Down
Loading