summaryrefslogtreecommitdiff
path: root/unittests
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
commit68065ba0432738172a882616b111ebda912a0466 (patch)
treef54b12a9b74c93c6361d4f820b4ffb23f9d3ae9e /unittests
parent408b811d1ee422aa06beab5b9c488a43dc74ce75 (diff)
[Coverage] Combine counts of expansion regions if there are no code regions for the same area.
Differential Revision: http://reviews.llvm.org/D18831 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ProfileData/CoverageMappingTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/ProfileData/CoverageMappingTest.cpp b/unittests/ProfileData/CoverageMappingTest.cpp
index b20d30f7bba..d788a6140e0 100644
--- a/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/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)));