summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-05-05 09:39:45 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-05-05 09:39:45 +0000
commit27d8dd39cf3c1fde9ce24bf7a5e8a36ce232582b (patch)
treee895dfc22976db0f728b7db8e9006335c0300bd9 /llvm/unittests/ProfileData/CoverageMappingTest.cpp
parentbb06ffaff39b9d0a1f008b5fa49438b1641e500c (diff)
downloadbcm5719-llvm-27d8dd39cf3c1fde9ce24bf7a5e8a36ce232582b.tar.gz
bcm5719-llvm-27d8dd39cf3c1fde9ce24bf7a5e8a36ce232582b.zip
[Coverage] Combine counts of expansion regions if there are no code regions for the same area.
Differential Revision: http://reviews.llvm.org/D18831 llvm-svn: 268620
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/CoverageMappingTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index b20d30f7bba..d788a6140e0 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -422,6 +422,8 @@ TEST_P(MaybeSparseCoverageMappingTest,
EXPECT_EQ(CoverageSegment(9, 9, false), Segments[3]);
}
+// If CodeRegions and ExpansionRegions cover the same area,
+// only counts of CodeRegions should be used.
TEST_P(MaybeSparseCoverageMappingTest, dont_combine_expansions) {
InstrProfRecord Record1("func", 0x1234, {10, 20});
InstrProfRecord Record2("func", 0x1234, {0, 0});
@@ -444,6 +446,29 @@ TEST_P(MaybeSparseCoverageMappingTest, dont_combine_expansions) {
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]);
}
+// If an area is covered only by ExpansionRegions, they should be combinated.
+TEST_P(MaybeSparseCoverageMappingTest, combine_expansions) {
+ InstrProfRecord Record("func", 0x1234, {2, 3, 7});
+ NoError(ProfileWriter.addRecord(std::move(Record)));
+
+ startFunction("func", 0x1234);
+ addCMR(Counter::getCounter(1), "include1", 1, 1, 1, 10);
+ addCMR(Counter::getCounter(2), "include2", 1, 1, 1, 10);
+ addCMR(Counter::getCounter(0), "file", 1, 1, 5, 5);
+ addExpansionCMR("file", "include1", 3, 1, 3, 5);
+ addExpansionCMR("file", "include2", 3, 1, 3, 5);
+
+ loadCoverageMapping();
+
+ CoverageData Data = LoadedCoverage->getCoverageForFile("file");
+ std::vector<CoverageSegment> Segments(Data.begin(), Data.end());
+ ASSERT_EQ(4U, Segments.size());
+ EXPECT_EQ(CoverageSegment(1, 1, 2, true), Segments[0]);
+ EXPECT_EQ(CoverageSegment(3, 1, 10, true), Segments[1]);
+ EXPECT_EQ(CoverageSegment(3, 5, 2, false), Segments[2]);
+ EXPECT_EQ(CoverageSegment(5, 5, false), Segments[3]);
+}
+
TEST_P(MaybeSparseCoverageMappingTest, strip_filename_prefix) {
InstrProfRecord Record("file1:func", 0x1234, {0});
NoError(ProfileWriter.addRecord(std::move(Record)));
OpenPOWER on IntegriCloud