19 using namespace coverage;
23 for (
const auto &Filename : Filenames) {
32 class CounterExpressionsMinimizer {
35 std::vector<unsigned> AdjustedExpressionIDs;
42 AdjustedExpressionIDs[
ID] = 1;
52 UsedExpressions.push_back(
E);
59 : Expressions(Expressions) {
60 AdjustedExpressionIDs.resize(Expressions.
size(), 0);
61 for (
const auto &
I : MappingRegions)
63 for (
const auto &
I : MappingRegions)
113 MappingRegions.begin(), MappingRegions.end(),
115 if (LHS.
FileID != RHS.FileID)
116 return LHS.
FileID < RHS.FileID;
117 if (LHS.
startLoc() != RHS.startLoc())
118 return LHS.
startLoc() < RHS.startLoc();
119 return LHS.
Kind < RHS.Kind;
124 for (
const auto &FileID : VirtualFileMapping)
128 CounterExpressionsMinimizer Minimizer(Expressions, MappingRegions);
129 auto MinExpressions = Minimizer.getExpressions();
131 for (
const auto &
E : MinExpressions) {
139 unsigned PrevLineStart = 0;
140 unsigned CurrentFileID = ~0U;
141 for (
auto I = MappingRegions.begin(),
E = MappingRegions.end();
I !=
E; ++
I) {
142 if (
I->FileID != CurrentFileID) {
144 assert(
I->FileID == (CurrentFileID + 1));
146 unsigned RegionCount = 1;
147 for (
auto J =
I + 1; J !=
E &&
I->FileID == J->FileID; ++J)
152 CurrentFileID =
I->FileID;
155 Counter Count = Minimizer.adjust(
I->Count);
163 (std::numeric_limits<unsigned>::max() >>
167 unsigned EncodedTagExpandedFileID =
181 assert(
I->LineStart >= PrevLineStart);
187 PrevLineStart =
I->LineStart;
190 assert(CurrentFileID == (VirtualFileMapping.size() - 1));
void write(raw_ostream &OS)
Write encoded coverage mapping data to the given output stream.
void write(raw_ostream &OS)
Write encoded filenames to the given output stream.
gvn Early GVN Hoisting of Expressions
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
static unsigned encodeCounter(ArrayRef< CounterExpression > Expressions, Counter C)
Encode the counter.
unsigned getExpressionID() const
CounterKind getKind() const
A CodeRegion associates some code with a counter.
unsigned getCounterID() const
A Counter mapping region associates a source range with a specific counter.
std::pair< unsigned, unsigned > startLoc() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
static void writeCounter(ArrayRef< CounterExpression > Expressions, Counter C, raw_ostream &OS)
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
bool isExpression() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const unsigned EncodingTagBits
This class implements an extremely fast bulk output stream that can only output to a stream...
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
A Counter is an abstract value that describes how to compute the execution count for a region of code...