summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/InstrProfTest.cpp
diff options
context:
space:
mode:
authorNathan Slingerland <slingn@gmail.com>2015-12-04 00:00:20 +0000
committerNathan Slingerland <slingn@gmail.com>2015-12-04 00:00:20 +0000
commit2a3dbe8be21a686d18f21fd1a5bcdbafc5c9a93a (patch)
treec70acf671827b14976616f04a172df28577c7c93 /llvm/unittests/ProfileData/InstrProfTest.cpp
parent09330577ffad57a63f51d5af0ffa1dc81d982781 (diff)
downloadbcm5719-llvm-2a3dbe8be21a686d18f21fd1a5bcdbafc5c9a93a.tar.gz
bcm5719-llvm-2a3dbe8be21a686d18f21fd1a5bcdbafc5c9a93a.zip
[llvm-profdata] Add support for weighted merge of profile data
This change adds support for an optional weight when merging profile data with the llvm-profdata tool. Weights are specified by adding an option ':<weight>' suffix to the input file names. Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the input data from multiple training runs. Both sampled and instrumented profiles are supported. Reviewers: dnovillo, bogner, davidxl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14547 llvm-svn: 254669
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 635a5431a51..946afdadba9 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -490,4 +490,24 @@ TEST_F(InstrProfTest, get_max_function_count) {
ASSERT_EQ(1ULL << 63, Reader->getMaximumFunctionCount());
}
+TEST_F(InstrProfTest, get_weighted_function_counts) {
+ InstrProfRecord Record1("foo", 0x1234, {1, 2});
+ InstrProfRecord Record2("foo", 0x1235, {3, 4});
+ Writer.addRecord(std::move(Record1), 3);
+ Writer.addRecord(std::move(Record2), 5);
+ auto Profile = Writer.writeBuffer();
+ readProfile(std::move(Profile));
+
+ std::vector<uint64_t> Counts;
+ ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1234, Counts)));
+ ASSERT_EQ(2U, Counts.size());
+ ASSERT_EQ(3U, Counts[0]);
+ ASSERT_EQ(6U, Counts[1]);
+
+ ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1235, Counts)));
+ ASSERT_EQ(2U, Counts.size());
+ ASSERT_EQ(15U, Counts[0]);
+ ASSERT_EQ(20U, Counts[1]);
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud