diff options
| author | Vedant Kumar <vsk@apple.com> | 2017-10-16 23:47:10 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2017-10-16 23:47:10 +0000 |
| commit | 58548c30daf80c77a07b78954054246d4072dc07 (patch) | |
| tree | ebc8d46f65fd9566fae9a2139d0f4697a98e5120 /llvm/tools/llvm-cov | |
| parent | 1fada3b90ac49a40685ba039552c167f33e251cb (diff) | |
| download | bcm5719-llvm-58548c30daf80c77a07b78954054246d4072dc07.tar.gz bcm5719-llvm-58548c30daf80c77a07b78954054246d4072dc07.zip | |
[llvm-cov] Remove workaround in line execution count calculation (PR34962)
Gap areas make it possible to correctly determine when to use counts
from deferred regions. Before gap areas were introduced, llvm-cov needed
to use a heuristic to do this: it ignored counts from segments that
start, but do not end, on a line. This heuristic breaks down on a simple
example (see PR34962).
This patch removes the heuristic and picks counts from any region entry
segment which isn't a gap area.
llvm-svn: 315960
Diffstat (limited to 'llvm/tools/llvm-cov')
| -rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp index 89948720504..0fa9e5b81bc 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp @@ -43,23 +43,16 @@ LineCoverageStats::LineCoverageStats( if (!Mapped) return; - // Pick the max count among regions which start and end on this line, to - // avoid erroneously using the wrapped count, and to avoid picking region - // counts which come from deferred regions. - if (LineSegments.size() > 1) { - for (unsigned I = 0; I < LineSegments.size() - 1; ++I) { - if (!LineSegments[I]->IsGapRegion) - ExecutionCount = std::max(ExecutionCount, LineSegments[I]->Count); - } + // Pick the max count from the non-gap, region entry segments. If there + // aren't any, use the wrapepd count. + if (HasMultipleRegions) { + for (const auto *LS : LineSegments) + if (isStartOfRegion(LS)) + ExecutionCount = std::max(ExecutionCount, LS->Count); return; } - - // If a non-gap region starts here, use its count. Otherwise use the wrapped - // count. - if (MinRegionCount == 1) - ExecutionCount = LineSegments[0]->Count; - else - ExecutionCount = WrappedSegment->Count; + ExecutionCount = + (MinRegionCount == 1) ? LineSegments[0]->Count : WrappedSegment->Count; } LineCoverageIterator &LineCoverageIterator::operator++() { |

