llvm.org GIT mirror llvm / 42ab8c0
InstrProf: Treat functions with a coverage map but no profile as unreached If we have a coverage mapping but no profile data for a function, calling it mismatched is misleading. This can just as easily be unreachable code that was stripped from the binary. Instead, treat these the same as functions where we have an explicit "zero" coverage map by setting the count to zero for each mapped region. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237298 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 4 years ago
2 changed file(s) with 18 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
208208 continue;
209209 } else if (EC != instrprof_error::unknown_function)
210210 return EC;
211 } else
212 Ctx.setCounts(Counts);
211 Counts.assign(Record.MappingRegions.size(), 0);
212 }
213 Ctx.setCounts(Counts);
213214
214215 assert(!Record.MappingRegions.empty() && "Function has no regions");
215216
221221 ASSERT_EQ(CoverageSegment(3, 4, false), Segments[1]);
222222 }
223223
224 TEST_F(CoverageMappingTest, uncovered_function_with_mapping) {
225 readProfCounts();
226
227 addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);
228 addCMR(Counter::getCounter(1), "file1", 1, 1, 4, 7);
229 loadCoverageMapping("func", 0x1234);
230
231 CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
232 std::vector Segments(Data.begin(), Data.end());
233 ASSERT_EQ(3U, Segments.size());
234 ASSERT_EQ(CoverageSegment(1, 1, 0, true), Segments[0]);
235 ASSERT_EQ(CoverageSegment(4, 7, 0, false), Segments[1]);
236 ASSERT_EQ(CoverageSegment(9, 9, false), Segments[2]);
237 }
238
224239 TEST_F(CoverageMappingTest, combine_regions) {
225240 ProfileWriter.addFunctionCounts("func", 0x1234, {10, 20, 30});
226241 readProfCounts();