================ @@ -676,24 +722,66 @@ TEST_P(InstrProfReaderWriterTest, icall_data_read_write) { Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234); ASSERT_THAT_ERROR(R.takeError(), Succeeded()); + + // Test the number of instrumented indirect call sites and the number of + // profiled values at each site. ASSERT_EQ(4U, R->getNumValueSites(IPVK_IndirectCallTarget)); EXPECT_EQ(3U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 0)); EXPECT_EQ(0U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 1)); EXPECT_EQ(2U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 2)); - EXPECT_EQ(1U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 3)); + EXPECT_EQ(2U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 3)); + + // Test the number of instrumented vtable sites and the number of profiled + // values at each site. + ASSERT_EQ(2U, R->getNumValueSites(IPVK_VTableTarget)); + EXPECT_EQ(3U, R->getNumValueDataForSite(IPVK_VTableTarget, 0)); + EXPECT_EQ(2U, R->getNumValueDataForSite(IPVK_VTableTarget, 1)); + + // First indirect site. + { + uint64_t TotalC; + std::unique_ptr<InstrProfValueData[]> VD = + R->getValueForSite(IPVK_IndirectCallTarget, 0, &TotalC); + + EXPECT_EQ(3U * getProfWeight(), VD[0].Count); + EXPECT_EQ(2U * getProfWeight(), VD[1].Count); + EXPECT_EQ(1U * getProfWeight(), VD[2].Count); + EXPECT_EQ(6U * getProfWeight(), TotalC); + + EXPECT_EQ(StringRef((const char *)VD[0].Value, 7), StringRef("callee3")); ---------------- minglotus-6 wrote:
done. https://github.com/llvm/llvm-project/pull/66825 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits