mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-18 10:24:45 +00:00
llvm-cov: Combine segments that cover the same location
If we have multiple coverage counts for the same segment, we need to add them up rather than arbitrarily choosing one. This fixes that and adds a test with template instantiations to exercise it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218432 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -19,11 +19,14 @@
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ProfileData/CoverageMappingReader.h"
|
||||
#include "llvm/ProfileData/InstrProfReader.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace coverage;
|
||||
|
||||
#define DEBUG_TYPE "coverage-mapping"
|
||||
|
||||
CounterExpressionBuilder::CounterExpressionBuilder(unsigned NumCounterValues) {
|
||||
Terms.resize(NumCounterValues);
|
||||
}
|
||||
@@ -228,6 +231,7 @@ class SegmentBuilder {
|
||||
|
||||
/// Start a segment with no count specified.
|
||||
void startSegment(unsigned Line, unsigned Col) {
|
||||
DEBUG(dbgs() << "Top level segment at " << Line << ":" << Col << "\n");
|
||||
Segments.emplace_back(Line, Col, /*IsRegionEntry=*/false);
|
||||
}
|
||||
|
||||
@@ -242,9 +246,13 @@ class SegmentBuilder {
|
||||
Segments.emplace_back(Line, Col, IsRegionEntry);
|
||||
S = Segments.back();
|
||||
}
|
||||
DEBUG(dbgs() << "Segment at " << Line << ":" << Col);
|
||||
// Set this region's count.
|
||||
if (Region.Kind != coverage::CounterMappingRegion::SkippedRegion)
|
||||
if (Region.Kind != coverage::CounterMappingRegion::SkippedRegion) {
|
||||
DEBUG(dbgs() << " with count " << Region.ExecutionCount);
|
||||
Segments.back().setCount(Region.ExecutionCount);
|
||||
}
|
||||
DEBUG(dbgs() << "\n");
|
||||
}
|
||||
|
||||
/// Start a segment for the given region.
|
||||
@@ -272,9 +280,15 @@ public:
|
||||
while (!ActiveRegions.empty() &&
|
||||
ActiveRegions.back()->endLoc() <= Region.startLoc())
|
||||
popRegion();
|
||||
// Add this region to the stack.
|
||||
ActiveRegions.push_back(&Region);
|
||||
startSegment(Region);
|
||||
if (Segments.size() && Segments.back().Line == Region.LineStart &&
|
||||
Segments.back().Col == Region.ColumnStart) {
|
||||
if (Region.Kind != coverage::CounterMappingRegion::SkippedRegion)
|
||||
Segments.back().addCount(Region.ExecutionCount);
|
||||
} else {
|
||||
// Add this region to the stack.
|
||||
ActiveRegions.push_back(&Region);
|
||||
startSegment(Region);
|
||||
}
|
||||
}
|
||||
// Pop any regions that are left in the stack.
|
||||
while (!ActiveRegions.empty())
|
||||
|
Reference in New Issue
Block a user