mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-29 22:30:33 +00:00
InstrProf: Don't combine expansion regions with code regions
This was leading to duplicate counts when a code region happened to overlap exactly with an expansion. The combining behaviour only makes sense for code regions. llvm-svn: 229723
This commit is contained in:
parent
3963f3adef
commit
485508085b
@ -314,7 +314,7 @@ public:
|
||||
popRegion();
|
||||
if (PrevRegion && PrevRegion->startLoc() == Region.startLoc() &&
|
||||
PrevRegion->endLoc() == Region.endLoc()) {
|
||||
if (Region.Kind != coverage::CounterMappingRegion::SkippedRegion)
|
||||
if (Region.Kind == coverage::CounterMappingRegion::CodeRegion)
|
||||
Segments.back().addCount(Region.ExecutionCount);
|
||||
} else {
|
||||
// Add this region to the stack.
|
||||
|
@ -222,4 +222,41 @@ TEST_F(CoverageMappingTest, uncovered_function) {
|
||||
ASSERT_EQ(CoverageSegment(3, 4, false), Segments[1]);
|
||||
}
|
||||
|
||||
TEST_F(CoverageMappingTest, combine_regions) {
|
||||
ProfileWriter.addFunctionCounts("func", 0x1234, {10, 20, 30});
|
||||
readProfCounts();
|
||||
|
||||
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);
|
||||
addCMR(Counter::getCounter(1), "file1", 3, 3, 4, 4);
|
||||
addCMR(Counter::getCounter(2), "file1", 3, 3, 4, 4);
|
||||
loadCoverageMapping("func", 0x1234);
|
||||
|
||||
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
|
||||
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());
|
||||
ASSERT_EQ(4U, Segments.size());
|
||||
ASSERT_EQ(CoverageSegment(1, 1, 10, true), Segments[0]);
|
||||
ASSERT_EQ(CoverageSegment(3, 3, 50, true), Segments[1]);
|
||||
ASSERT_EQ(CoverageSegment(4, 4, 10, false), Segments[2]);
|
||||
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]);
|
||||
}
|
||||
|
||||
TEST_F(CoverageMappingTest, dont_combine_expansions) {
|
||||
ProfileWriter.addFunctionCounts("func", 0x1234, {10, 20});
|
||||
readProfCounts();
|
||||
|
||||
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);
|
||||
addCMR(Counter::getCounter(1), "file1", 3, 3, 4, 4);
|
||||
addCMR(Counter::getCounter(1), "include1", 6, 6, 7, 7);
|
||||
addExpansionCMR("file1", "include1", 3, 3, 4, 4);
|
||||
loadCoverageMapping("func", 0x1234);
|
||||
|
||||
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
|
||||
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());
|
||||
ASSERT_EQ(4U, Segments.size());
|
||||
ASSERT_EQ(CoverageSegment(1, 1, 10, true), Segments[0]);
|
||||
ASSERT_EQ(CoverageSegment(3, 3, 20, true), Segments[1]);
|
||||
ASSERT_EQ(CoverageSegment(4, 4, 10, false), Segments[2]);
|
||||
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user