aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/InstrProfTest.cpp
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2016-02-12 21:36:17 +0000
committerRong Xu <xur@google.com>2016-02-12 21:36:17 +0000
commitbb49490de1dea43b036ecb9db09b4e6cce0b04b6 (patch)
treedf6a4a281efede228f3947dcc306b9109955ae32 /llvm/unittests/ProfileData/InstrProfTest.cpp
parenta6771b37f814b6c5d3f547323d9c49babef4844b (diff)
downloadllvm-bb49490de1dea43b036ecb9db09b4e6cce0b04b6.zip
llvm-bb49490de1dea43b036ecb9db09b4e6cce0b04b6.tar.gz
llvm-bb49490de1dea43b036ecb9db09b4e6cce0b04b6.tar.bz2
[PGO] Add another interface for annotateValueSite
Add another interface to function annotateValueSite() which directly uses the VauleData array. Differential Revision: http://reviews.llvm.org/D17108 llvm-svn: 260741
Diffstat (limited to 'llvm/unittests/ProfileData/InstrProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/InstrProfTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 0fe1b30..31dca3c 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -299,6 +299,26 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
ASSERT_EQ(3U, ValueData[3].Count);
ASSERT_EQ(2000U, ValueData[4].Value);
ASSERT_EQ(2U, ValueData[4].Count);
+
+ // Remove the MD_prof metadata
+ Inst->setMetadata(LLVMContext::MD_prof, 0);
+ // Annotate with 4 records.
+ InstrProfValueData VD0Sorted[] = {{1000, 6}, {2000, 5}, {3000, 4}, {4000, 3},
+ {5000, 2}, {6000, 1}};
+ annotateValueSite(*M, *Inst, &VD0Sorted[2], 4, 10, IPVK_IndirectCallTarget, 5);
+ Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5,
+ ValueData, N, T);
+ ASSERT_TRUE(Res);
+ ASSERT_EQ(4U, N);
+ ASSERT_EQ(10U, T);
+ ASSERT_EQ(3000U, ValueData[0].Value);
+ ASSERT_EQ(4U, ValueData[0].Count);
+ ASSERT_EQ(4000U, ValueData[1].Value);
+ ASSERT_EQ(3U, ValueData[1].Count);
+ ASSERT_EQ(5000U, ValueData[2].Value);
+ ASSERT_EQ(2U, ValueData[2].Count);
+ ASSERT_EQ(6000U, ValueData[3].Value);
+ ASSERT_EQ(1U, ValueData[3].Count);
}
TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_with_weight) {