[llvm] 180a536 - [ProfileData] Fix the order of tests (#95549)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 09:18:35 PDT 2024


Author: Kazu Hirata
Date: 2024-06-14T09:18:31-07:00
New Revision: 180a536665127bded6c7ef1755e9dd0edfa8802f

URL: https://github.com/llvm/llvm-project/commit/180a536665127bded6c7ef1755e9dd0edfa8802f
DIFF: https://github.com/llvm/llvm-project/commit/180a536665127bded6c7ef1755e9dd0edfa8802f.diff

LOG: [ProfileData] Fix the order of tests (#95549)

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.

Added: 
    

Modified: 
    llvm/unittests/ProfileData/InstrProfTest.cpp

Removed: 
    


################################################################################
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);


        


More information about the llvm-commits mailing list