[llvm] [ProfileData] Migrate to getValueArrayForSite (PR #95493)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 22:48:01 PDT 2024
================
@@ -1466,17 +1468,19 @@ TEST(ValueProfileReadWriteTest, value_prof_data_read_write) {
EXPECT_EQ(VD1[3].Value, getCalleeAddress(vtable5));
EXPECT_EQ(VD1[3].Count, 800U);
- auto VD2(Record.getValueForSite(IPVK_VTableTarget, 2));
- llvm::sort(&VD2[0], &VD2[3], Cmp);
+ SmallVector<InstrProfValueData> VD2(
+ Record.getValueArrayForSite(IPVK_VTableTarget, 2));
+ llvm::sort(VD2, Cmp);
EXPECT_EQ(VD2[0].Value, getCalleeAddress(vtable4));
EXPECT_EQ(VD2[0].Count, 5500U);
EXPECT_EQ(VD2[1].Value, getCalleeAddress(vtable3));
EXPECT_EQ(VD2[1].Count, 1000U);
EXPECT_EQ(VD2[2].Value, getCalleeAddress(vtable6));
EXPECT_EQ(VD2[2].Count, 800U);
- auto VD3(Record.getValueForSite(IPVK_VTableTarget, 3));
- llvm::sort(&VD3[0], &VD3[2], Cmp);
+ SmallVector<InstrProfValueData> VD3(
----------------
kazutakahirata wrote:
I'm afraid that you are misreading here. The old API `getValueForSite` creates a copy in the form of `std::unique_ptr<InstrProfValueData[]>`. The new API `getValueArrayForSite` returns `ArrayRef<InstrProfValueData>`, so we create a copy on our own with `SmallVector<InstrProfValueData>`. Either way, `llvm::sort` sorts a copy. Nobody is modifying the original stored in `Record`.
https://github.com/llvm/llvm-project/pull/95493
More information about the llvm-commits
mailing list