mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-30 04:35:00 +00:00
Coverage: add HasCodeBefore flag to a mapping region.
This flag will be used by the coverage tool to help compute the execution counts for each line in a source file. Differential Revision: http://reviews.llvm.org/D4746 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b88bbc0e9d
commit
aafa4b5c86
@ -144,17 +144,24 @@ struct CounterMappingRegion {
|
|||||||
SkippedRegion
|
SkippedRegion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const unsigned EncodingHasCodeBeforeBits = 1;
|
||||||
|
|
||||||
Counter Count;
|
Counter Count;
|
||||||
unsigned FileID, ExpandedFileID;
|
unsigned FileID, ExpandedFileID;
|
||||||
unsigned LineStart, ColumnStart, LineEnd, ColumnEnd;
|
unsigned LineStart, ColumnStart, LineEnd, ColumnEnd;
|
||||||
RegionKind Kind;
|
RegionKind Kind;
|
||||||
|
/// \brief A flag that is set to true when there is already code before
|
||||||
|
/// this region on the same line.
|
||||||
|
/// This is useful to accurately compute the execution counts for a line.
|
||||||
|
bool HasCodeBefore;
|
||||||
|
|
||||||
CounterMappingRegion(Counter Count, unsigned FileID, unsigned LineStart,
|
CounterMappingRegion(Counter Count, unsigned FileID, unsigned LineStart,
|
||||||
unsigned ColumnStart, unsigned LineEnd,
|
unsigned ColumnStart, unsigned LineEnd,
|
||||||
unsigned ColumnEnd, RegionKind Kind = CodeRegion)
|
unsigned ColumnEnd, bool HasCodeBefore = false,
|
||||||
|
RegionKind Kind = CodeRegion)
|
||||||
: Count(Count), FileID(FileID), ExpandedFileID(0), LineStart(LineStart),
|
: Count(Count), FileID(FileID), ExpandedFileID(0), LineStart(LineStart),
|
||||||
ColumnStart(ColumnStart), LineEnd(LineEnd), ColumnEnd(ColumnEnd),
|
ColumnStart(ColumnStart), LineEnd(LineEnd), ColumnEnd(ColumnEnd),
|
||||||
Kind(Kind) {}
|
Kind(Kind), HasCodeBefore(HasCodeBefore) {}
|
||||||
|
|
||||||
bool operator<(const CounterMappingRegion &Other) const {
|
bool operator<(const CounterMappingRegion &Other) const {
|
||||||
if (FileID != Other.FileID)
|
if (FileID != Other.FileID)
|
||||||
|
@ -170,13 +170,17 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the source range.
|
// Read the source range.
|
||||||
uint64_t LineStartDelta, ColumnStart, NumLines, ColumnEnd;
|
uint64_t LineStartDelta, CodeBeforeColumnStart, NumLines, ColumnEnd;
|
||||||
if (auto Err =
|
if (auto Err =
|
||||||
readIntMax(LineStartDelta, std::numeric_limits<unsigned>::max()))
|
readIntMax(LineStartDelta, std::numeric_limits<unsigned>::max()))
|
||||||
return Err;
|
return Err;
|
||||||
if (auto Err =
|
if (auto Err = readULEB128(CodeBeforeColumnStart))
|
||||||
readIntMax(ColumnStart, std::numeric_limits<unsigned>::max()))
|
|
||||||
return Err;
|
return Err;
|
||||||
|
bool HasCodeBefore = CodeBeforeColumnStart & 1;
|
||||||
|
uint64_t ColumnStart = CodeBeforeColumnStart >>
|
||||||
|
CounterMappingRegion::EncodingHasCodeBeforeBits;
|
||||||
|
if (ColumnStart > std::numeric_limits<unsigned>::max())
|
||||||
|
return error(instrprof_error::malformed);
|
||||||
if (auto Err = readIntMax(NumLines, std::numeric_limits<unsigned>::max()))
|
if (auto Err = readIntMax(NumLines, std::numeric_limits<unsigned>::max()))
|
||||||
return Err;
|
return Err;
|
||||||
if (auto Err = readIntMax(ColumnEnd, std::numeric_limits<unsigned>::max()))
|
if (auto Err = readIntMax(ColumnEnd, std::numeric_limits<unsigned>::max()))
|
||||||
@ -194,9 +198,9 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray(
|
|||||||
ColumnStart = 1;
|
ColumnStart = 1;
|
||||||
ColumnEnd = std::numeric_limits<unsigned>::max();
|
ColumnEnd = std::numeric_limits<unsigned>::max();
|
||||||
}
|
}
|
||||||
MappingRegions.push_back(
|
MappingRegions.push_back(CounterMappingRegion(
|
||||||
CounterMappingRegion(C, InferredFileID, LineStart, ColumnStart,
|
C, InferredFileID, LineStart, ColumnStart, LineStart + NumLines,
|
||||||
LineStart + NumLines, ColumnEnd, Kind));
|
ColumnEnd, HasCodeBefore, Kind));
|
||||||
MappingRegions.back().ExpandedFileID = ExpandedFileID;
|
MappingRegions.back().ExpandedFileID = ExpandedFileID;
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
|
@ -181,7 +181,11 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
|
|||||||
}
|
}
|
||||||
assert(I.LineStart >= PrevLineStart);
|
assert(I.LineStart >= PrevLineStart);
|
||||||
encodeULEB128(I.LineStart - PrevLineStart, OS);
|
encodeULEB128(I.LineStart - PrevLineStart, OS);
|
||||||
encodeULEB128(I.ColumnStart, OS);
|
uint64_t CodeBeforeColumnStart =
|
||||||
|
uint64_t(I.HasCodeBefore) |
|
||||||
|
(uint64_t(I.ColumnStart)
|
||||||
|
<< CounterMappingRegion::EncodingHasCodeBeforeBits);
|
||||||
|
encodeULEB128(CodeBeforeColumnStart, OS);
|
||||||
assert(I.LineEnd >= I.LineStart);
|
assert(I.LineEnd >= I.LineStart);
|
||||||
encodeULEB128(I.LineEnd - I.LineStart, OS);
|
encodeULEB128(I.LineEnd - I.LineStart, OS);
|
||||||
encodeULEB128(I.ColumnEnd, OS);
|
encodeULEB128(I.ColumnEnd, OS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user