llvm.org GIT mirror llvm / dea3d88
[Coverage] Scan ahead for the most-recent completed count (PR35495) This extends r319391. It teaches the segment builder to emit the right completed segment when more than one region ends at the same location. Fixes PR35495. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319990 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 10 months ago
2 changed file(s) with 13 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
387387 if (CompletedSegmentLoc == CompletedRegion->endLoc())
388388 continue;
389389
390 // Use the count from the next completed region if it ends at the same
391 // location.
392 if (I + 1 < E &&
393 CompletedRegion->endLoc() == ActiveRegions[I + 1]->endLoc())
394 CompletedRegion = ActiveRegions[I + 1];
390 // Use the count from the last completed region which ends at this loc.
391 for (unsigned J = I + 1; J < E; ++J)
392 if (CompletedRegion->endLoc() == ActiveRegions[J]->endLoc())
393 CompletedRegion = ActiveRegions[J];
395394
396395 startSegment(*CompletedRegion, CompletedSegmentLoc, false);
397396 }
469469 ProfileWriter.addRecord({"func1", 0x1234, {0, 1, 2}}, Err);
470470 startFunction("func1", 0x1234);
471471
472 // PR35437
472 // PR35495
473473 addCMR(Counter::getCounter(1), "file1", 2, 1, 18, 2);
474 addCMR(Counter::getCounter(0), "file1", 8, 10, 14, 6);
474475 addCMR(Counter::getCounter(0), "file1", 8, 12, 14, 6);
475476 addCMR(Counter::getCounter(1), "file1", 9, 1, 14, 6);
476477 addCMR(Counter::getCounter(2), "file1", 11, 13, 11, 14);
481482 CoverageData Data = LoadedCoverage->getCoverageForFunction(FunctionRecord);
482483 std::vector Segments(Data.begin(), Data.end());
483484
484 ASSERT_EQ(6U, Segments.size());
485 ASSERT_EQ(7U, Segments.size());
485486 EXPECT_EQ(CoverageSegment(2, 1, 1, true), Segments[0]);
486 EXPECT_EQ(CoverageSegment(8, 12, 0, true), Segments[1]);
487 EXPECT_EQ(CoverageSegment(9, 1, 1, true), Segments[2]);
488 EXPECT_EQ(CoverageSegment(11, 13, 2, true), Segments[3]);
487 EXPECT_EQ(CoverageSegment(8, 10, 0, true), Segments[1]);
488 EXPECT_EQ(CoverageSegment(8, 12, 0, true), Segments[2]);
489 EXPECT_EQ(CoverageSegment(9, 1, 1, true), Segments[3]);
490 EXPECT_EQ(CoverageSegment(11, 13, 2, true), Segments[4]);
489491 // Use count=1 (from 9:1 -> 14:6), not count=0 (from 8:12 -> 14:6).
490 EXPECT_EQ(CoverageSegment(11, 14, 1, false), Segments[4]);
491 EXPECT_EQ(CoverageSegment(18, 2, false), Segments[5]);
492 EXPECT_EQ(CoverageSegment(11, 14, 1, false), Segments[5]);
493 EXPECT_EQ(CoverageSegment(18, 2, false), Segments[6]);
492494 }
493495
494496 TEST_P(CoverageMappingTest, dont_emit_redundant_segments) {