Go to the documentation of this file.
27 using namespace coverage;
31 : Filenames(Filenames) {
40 std::string FilenamesStr;
43 for (
const auto &Filename : Filenames) {
45 FilenamesOS << Filename;
62 OS << (doCompression ? CompressedStr.
str() :
StringRef(FilenamesStr));
69 class CounterExpressionsMinimizer {
72 std::vector<unsigned> AdjustedExpressionIDs;
78 AdjustedExpressionIDs.resize(
Expressions.size(), 0);
79 for (
const auto &
I : MappingRegions) {
83 for (
const auto &
I : MappingRegions) {
85 gatherUsed(
I.FalseCount);
90 if (!
C.isExpression())
92 unsigned ID =
C.getExpressionID();
93 AdjustedExpressionIDs[
ID] = 1;
99 if (!
C.isExpression() || !AdjustedExpressionIDs[
C.getExpressionID()])
101 AdjustedExpressionIDs[
C.getExpressionID()] = UsedExpressions.size();
103 UsedExpressions.push_back(
E);
113 if (
C.isExpression())
137 unsigned Tag = unsigned(
C.getKind());
138 if (
C.isExpression())
140 unsigned ID =
C.getCounterID();
157 "Source region does not begin before it ends");
163 if (
LHS.FileID !=
RHS.FileID)
164 return LHS.FileID <
RHS.FileID;
165 if (
LHS.startLoc() !=
RHS.startLoc())
166 return LHS.startLoc() <
RHS.startLoc();
167 return LHS.Kind <
RHS.Kind;
172 for (
const auto &FileID : VirtualFileMapping)
176 CounterExpressionsMinimizer Minimizer(
Expressions, MappingRegions);
177 auto MinExpressions = Minimizer.getExpressions();
179 for (
const auto &
E : MinExpressions) {
187 unsigned PrevLineStart = 0;
188 unsigned CurrentFileID = ~0U;
189 for (
auto I = MappingRegions.begin(),
E = MappingRegions.end();
I !=
E; ++
I) {
190 if (
I->FileID != CurrentFileID) {
192 assert(
I->FileID == (CurrentFileID + 1));
194 unsigned RegionCount = 1;
195 for (
auto J =
I + 1; J !=
E &&
I->FileID == J->FileID; ++J)
200 CurrentFileID =
I->FileID;
203 Counter Count = Minimizer.adjust(
I->Count);
204 Counter FalseCount = Minimizer.adjust(
I->FalseCount);
217 unsigned EncodedTagExpandedFileID =
238 assert(
I->LineStart >= PrevLineStart);
244 PrevLineStart =
I->LineStart;
247 assert(CurrentFileID == (VirtualFileMapping.size() - 1));
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
static void writeCounter(ArrayRef< CounterExpression > Expressions, Counter C, raw_ostream &OS)
This is an optimization pass for GlobalISel generic memory operations.
LineColPair endLoc() const
A Counter mapping region associates a source range with a specific counter.
A raw_ostream that writes to an std::string.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
@ ExpansionRegion
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
std::pair< typename Base::iterator, bool > insert(StringRef key)
static unsigned encodeCounter(ArrayRef< CounterExpression > Expressions, Counter C)
Encode the counter.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static constexpr int BestSizeCompression
void compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, int Level=DefaultCompression)
(vector float) vec_cmpeq(*A, *B) C
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void write(raw_ostream &OS, bool Compress=true)
Write encoded filenames to the given output stream.
A Counter is an abstract value that describes how to compute the execution count for a region of code...
void write(raw_ostream &OS)
Write encoded coverage mapping data to the given output stream.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LineColPair startLoc() const
@ BranchRegion
A BranchRegion represents leaf-level boolean expressions and is associated with two counters,...
@ GapRegion
A GapRegion is like a CodeRegion, but its count is only set as the line execution count when its the ...
StringSet - A wrapper for StringMap that provides set-like functionality.
StringRef - Represent a constant reference to a string, i.e.
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
if(llvm_vc STREQUAL "") set(fake_version_inc "$
cl::opt< bool > DoInstrProfNameCompression
void stable_sort(R &&Range)
StringRef str() const
Explicit conversion to StringRef.
gvn Early GVN Hoisting of Expressions
size_t size() const
size - Get the array size.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
@ CodeRegion
A CodeRegion associates some code with a counter.
static const unsigned EncodingTagBits
CoverageFilenamesSectionWriter(ArrayRef< std::string > Filenames)
@ SkippedRegion
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...