[llvm] [ProfileData] Fix the order of tests (PR #95549)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 07:22:00 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

Without this patch, we call getValueForSite before veryfing that we
have an expected number of value sites with getNumValueSites.

This patch fixes the order by "sinking" the call to getValueForSite.

While I am at it, this patch migrates the use of getValueForSite to
getValueArrayForSite.

---
Full diff: https://github.com/llvm/llvm-project/pull/95549.diff


1 Files Affected:

- (modified) llvm/unittests/ProfileData/InstrProfTest.cpp (+2-2) 


``````````diff
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index dae5542290934..54689e7669633 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1299,9 +1299,9 @@ TEST_P(ValueProfileMergeEdgeCaseTest, value_profile_data_merge_site_trunc) {
 
   Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);
   ASSERT_THAT_ERROR(R.takeError(), Succeeded());
-  std::unique_ptr<InstrProfValueData[]> VD(R->getValueForSite(ValueKind, 0));
   ASSERT_EQ(2U, R->getNumValueSites(ValueKind));
-  EXPECT_EQ(255U, R->getNumValueDataForSite(ValueKind, 0));
+  auto VD = R->getValueArrayForSite(ValueKind, 0);
+  EXPECT_THAT(VD, SizeIs(255));
   for (unsigned I = 0; I < 255; I++) {
     EXPECT_EQ(VD[I].Value, 509 - I);
     EXPECT_EQ(VD[I].Count, 1509 - I);

``````````

</details>


https://github.com/llvm/llvm-project/pull/95549


More information about the llvm-commits mailing list