mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[Coverage] Store compilation dir separately in coverage mapping
We currently always store absolute filenames in coverage mapping. This is problematic for several reasons. It poses a problem for distributed compilation as source location might vary across machines. We are also duplicating the path prefix potentially wasting space. This change modifies how we store filenames in coverage mapping. Rather than absolute paths, it stores the compilation directory and file paths as given to the compiler, either relative or absolute. Later when reading the coverage mapping information, we recombine relative paths with the working directory. This approach is similar to handling ofDW_AT_comp_dir in DWARF. Finally, we also provide a new option, -fprofile-compilation-dir akin to -fdebug-compilation-dir which can be used to manually override the compilation directory which is useful in distributed compilation cases. Differential Revision: https://reviews.llvm.org/D95753
This commit is contained in:
parent
3bda5a764e
commit
fd85f23c36
@ -266,7 +266,16 @@ too deeply).
|
|||||||
[32 x i8] c"..." ; Encoded data (dissected later)
|
[32 x i8] c"..." ; Encoded data (dissected later)
|
||||||
}, section "__llvm_covmap", align 8
|
}, section "__llvm_covmap", align 8
|
||||||
|
|
||||||
The current version of the format is version 5. There is one difference from version 4:
|
The current version of the format is version 6.
|
||||||
|
|
||||||
|
There is one difference between versions 6 and 5:
|
||||||
|
|
||||||
|
* The first entry in the filename list is the compilation directory. When the
|
||||||
|
filename is relative, the compilation directory is combined with the relative
|
||||||
|
path to get an absolute path. This can reduce size by omitting the duplicate
|
||||||
|
prefix in filenames.
|
||||||
|
|
||||||
|
There is one difference between versions 5 and 4:
|
||||||
|
|
||||||
* The notion of branch region has been introduced along with a corresponding
|
* The notion of branch region has been introduced along with a corresponding
|
||||||
region kind. Branch regions encode two counters, one to track how many
|
region kind. Branch regions encode two counters, one to track how many
|
||||||
|
@ -996,7 +996,10 @@ enum CovMapVersion {
|
|||||||
Version4 = 3,
|
Version4 = 3,
|
||||||
// Branch regions referring to two counters are added
|
// Branch regions referring to two counters are added
|
||||||
Version5 = 4,
|
Version5 = 4,
|
||||||
// The current version is Version5.
|
// Compilation directory is stored separately and combined with relative
|
||||||
|
// filenames to produce an absolute file path.
|
||||||
|
Version6 = 5,
|
||||||
|
// The current version is Version6.
|
||||||
CurrentVersion = INSTR_PROF_COVMAP_VERSION
|
CurrentVersion = INSTR_PROF_COVMAP_VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,14 +125,14 @@ public:
|
|||||||
|
|
||||||
/// Reader for the raw coverage mapping data.
|
/// Reader for the raw coverage mapping data.
|
||||||
class RawCoverageMappingReader : public RawCoverageReader {
|
class RawCoverageMappingReader : public RawCoverageReader {
|
||||||
ArrayRef<StringRef> TranslationUnitFilenames;
|
ArrayRef<std::string> &TranslationUnitFilenames;
|
||||||
std::vector<StringRef> &Filenames;
|
std::vector<StringRef> &Filenames;
|
||||||
std::vector<CounterExpression> &Expressions;
|
std::vector<CounterExpression> &Expressions;
|
||||||
std::vector<CounterMappingRegion> &MappingRegions;
|
std::vector<CounterMappingRegion> &MappingRegions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RawCoverageMappingReader(StringRef MappingData,
|
RawCoverageMappingReader(StringRef MappingData,
|
||||||
ArrayRef<StringRef> TranslationUnitFilenames,
|
ArrayRef<std::string> &TranslationUnitFilenames,
|
||||||
std::vector<StringRef> &Filenames,
|
std::vector<StringRef> &Filenames,
|
||||||
std::vector<CounterExpression> &Expressions,
|
std::vector<CounterExpression> &Expressions,
|
||||||
std::vector<CounterMappingRegion> &MappingRegions)
|
std::vector<CounterMappingRegion> &MappingRegions)
|
||||||
@ -174,10 +174,8 @@ public:
|
|||||||
FilenamesBegin(FilenamesBegin), FilenamesSize(FilenamesSize) {}
|
FilenamesBegin(FilenamesBegin), FilenamesSize(FilenamesSize) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using DecompressedData = std::vector<std::unique_ptr<SmallVector<char, 0>>>;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<StringRef> Filenames;
|
std::vector<std::string> Filenames;
|
||||||
std::vector<ProfileMappingRecord> MappingRecords;
|
std::vector<ProfileMappingRecord> MappingRecords;
|
||||||
InstrProfSymtab ProfileNames;
|
InstrProfSymtab ProfileNames;
|
||||||
size_t CurrentRecord = 0;
|
size_t CurrentRecord = 0;
|
||||||
@ -190,10 +188,6 @@ private:
|
|||||||
// D69471, which can split up function records into multiple sections on ELF.
|
// D69471, which can split up function records into multiple sections on ELF.
|
||||||
std::string FuncRecords;
|
std::string FuncRecords;
|
||||||
|
|
||||||
// Used to tie the lifetimes of decompressed strings to the lifetime of this
|
|
||||||
// BinaryCoverageReader instance.
|
|
||||||
DecompressedData Decompressed;
|
|
||||||
|
|
||||||
BinaryCoverageReader(std::string &&FuncRecords)
|
BinaryCoverageReader(std::string &&FuncRecords)
|
||||||
: FuncRecords(std::move(FuncRecords)) {}
|
: FuncRecords(std::move(FuncRecords)) {}
|
||||||
|
|
||||||
@ -216,20 +210,20 @@ public:
|
|||||||
|
|
||||||
/// Reader for the raw coverage filenames.
|
/// Reader for the raw coverage filenames.
|
||||||
class RawCoverageFilenamesReader : public RawCoverageReader {
|
class RawCoverageFilenamesReader : public RawCoverageReader {
|
||||||
std::vector<StringRef> &Filenames;
|
std::vector<std::string> &Filenames;
|
||||||
|
|
||||||
// Read an uncompressed sequence of filenames.
|
// Read an uncompressed sequence of filenames.
|
||||||
Error readUncompressed(uint64_t NumFilenames);
|
Error readUncompressed(CovMapVersion Version, uint64_t NumFilenames);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RawCoverageFilenamesReader(StringRef Data, std::vector<StringRef> &Filenames)
|
RawCoverageFilenamesReader(StringRef Data,
|
||||||
|
std::vector<std::string> &Filenames)
|
||||||
: RawCoverageReader(Data), Filenames(Filenames) {}
|
: RawCoverageReader(Data), Filenames(Filenames) {}
|
||||||
RawCoverageFilenamesReader(const RawCoverageFilenamesReader &) = delete;
|
RawCoverageFilenamesReader(const RawCoverageFilenamesReader &) = delete;
|
||||||
RawCoverageFilenamesReader &
|
RawCoverageFilenamesReader &
|
||||||
operator=(const RawCoverageFilenamesReader &) = delete;
|
operator=(const RawCoverageFilenamesReader &) = delete;
|
||||||
|
|
||||||
Error read(CovMapVersion Version,
|
Error read(CovMapVersion Version);
|
||||||
BinaryCoverageReader::DecompressedData &Decompressed);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace coverage
|
} // end namespace coverage
|
||||||
|
@ -27,10 +27,10 @@ namespace coverage {
|
|||||||
/// Writer of the filenames section for the instrumentation
|
/// Writer of the filenames section for the instrumentation
|
||||||
/// based code coverage.
|
/// based code coverage.
|
||||||
class CoverageFilenamesSectionWriter {
|
class CoverageFilenamesSectionWriter {
|
||||||
ArrayRef<StringRef> Filenames;
|
ArrayRef<std::string> Filenames;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames);
|
CoverageFilenamesSectionWriter(ArrayRef<std::string> Filenames);
|
||||||
|
|
||||||
/// Write encoded filenames to the given output stream. If \p Compress is
|
/// Write encoded filenames to the given output stream. If \p Compress is
|
||||||
/// true, attempt to compress the filenames.
|
/// true, attempt to compress the filenames.
|
||||||
|
@ -649,7 +649,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
|
|||||||
/* Indexed profile format version (start from 1). */
|
/* Indexed profile format version (start from 1). */
|
||||||
#define INSTR_PROF_INDEX_VERSION 7
|
#define INSTR_PROF_INDEX_VERSION 7
|
||||||
/* Coverage mapping format version (start from 0). */
|
/* Coverage mapping format version (start from 0). */
|
||||||
#define INSTR_PROF_COVMAP_VERSION 4
|
#define INSTR_PROF_COVMAP_VERSION 5
|
||||||
|
|
||||||
/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
|
/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
|
||||||
* version for other variants of profile. We set the lowest bit of the upper 8
|
* version for other variants of profile. We set the lowest bit of the upper 8
|
||||||
|
@ -97,9 +97,7 @@ Error RawCoverageReader::readString(StringRef &Result) {
|
|||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error RawCoverageFilenamesReader::read(
|
Error RawCoverageFilenamesReader::read(CovMapVersion Version) {
|
||||||
CovMapVersion Version,
|
|
||||||
BinaryCoverageReader::DecompressedData &Decompressed) {
|
|
||||||
uint64_t NumFilenames;
|
uint64_t NumFilenames;
|
||||||
if (auto Err = readSize(NumFilenames))
|
if (auto Err = readSize(NumFilenames))
|
||||||
return Err;
|
return Err;
|
||||||
@ -107,7 +105,7 @@ Error RawCoverageFilenamesReader::read(
|
|||||||
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
||||||
|
|
||||||
if (Version < CovMapVersion::Version4)
|
if (Version < CovMapVersion::Version4)
|
||||||
return readUncompressed(NumFilenames);
|
return readUncompressed(Version, NumFilenames);
|
||||||
|
|
||||||
// The uncompressed length may exceed the size of the encoded filenames.
|
// The uncompressed length may exceed the size of the encoded filenames.
|
||||||
// Skip size validation.
|
// Skip size validation.
|
||||||
@ -124,11 +122,8 @@ Error RawCoverageFilenamesReader::read(
|
|||||||
return make_error<CoverageMapError>(
|
return make_error<CoverageMapError>(
|
||||||
coveragemap_error::decompression_failed);
|
coveragemap_error::decompression_failed);
|
||||||
|
|
||||||
// Allocate memory for the decompressed filenames. Transfer ownership of
|
// Allocate memory for the decompressed filenames.
|
||||||
// the memory to BinaryCoverageReader.
|
SmallVector<char, 0> StorageBuf;
|
||||||
auto DecompressedStorage = std::make_unique<SmallVector<char, 0>>();
|
|
||||||
SmallVectorImpl<char> &StorageBuf = *DecompressedStorage.get();
|
|
||||||
Decompressed.push_back(std::move(DecompressedStorage));
|
|
||||||
|
|
||||||
// Read compressed filenames.
|
// Read compressed filenames.
|
||||||
StringRef CompressedFilenames = Data.substr(0, CompressedLen);
|
StringRef CompressedFilenames = Data.substr(0, CompressedLen);
|
||||||
@ -143,19 +138,40 @@ Error RawCoverageFilenamesReader::read(
|
|||||||
|
|
||||||
StringRef UncompressedFilenames(StorageBuf.data(), StorageBuf.size());
|
StringRef UncompressedFilenames(StorageBuf.data(), StorageBuf.size());
|
||||||
RawCoverageFilenamesReader Delegate(UncompressedFilenames, Filenames);
|
RawCoverageFilenamesReader Delegate(UncompressedFilenames, Filenames);
|
||||||
return Delegate.readUncompressed(NumFilenames);
|
return Delegate.readUncompressed(Version, NumFilenames);
|
||||||
}
|
}
|
||||||
|
|
||||||
return readUncompressed(NumFilenames);
|
return readUncompressed(Version, NumFilenames);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error RawCoverageFilenamesReader::readUncompressed(uint64_t NumFilenames) {
|
Error RawCoverageFilenamesReader::readUncompressed(CovMapVersion Version,
|
||||||
|
uint64_t NumFilenames) {
|
||||||
// Read uncompressed filenames.
|
// Read uncompressed filenames.
|
||||||
for (size_t I = 0; I < NumFilenames; ++I) {
|
if (Version < CovMapVersion::Version6) {
|
||||||
StringRef Filename;
|
for (size_t I = 0; I < NumFilenames; ++I) {
|
||||||
if (auto Err = readString(Filename))
|
StringRef Filename;
|
||||||
|
if (auto Err = readString(Filename))
|
||||||
|
return Err;
|
||||||
|
Filenames.push_back(Filename.str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
StringRef CWD;
|
||||||
|
if (auto Err = readString(CWD))
|
||||||
return Err;
|
return Err;
|
||||||
Filenames.push_back(Filename);
|
Filenames.push_back(CWD.str());
|
||||||
|
|
||||||
|
for (size_t I = 1; I < NumFilenames; ++I) {
|
||||||
|
StringRef Filename;
|
||||||
|
if (auto Err = readString(Filename))
|
||||||
|
return Err;
|
||||||
|
if (sys::path::is_absolute(Filename)) {
|
||||||
|
Filenames.push_back(Filename.str());
|
||||||
|
} else {
|
||||||
|
SmallString<256> P(CWD);
|
||||||
|
llvm::sys::path::append(P, Filename);
|
||||||
|
Filenames.push_back(static_cast<std::string>(P));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
@ -481,9 +497,8 @@ struct CovMapFuncRecordReader {
|
|||||||
//
|
//
|
||||||
// Returns a pointer to the next \c CovHeader if it exists, or to an address
|
// Returns a pointer to the next \c CovHeader if it exists, or to an address
|
||||||
// greater than \p CovEnd if not.
|
// greater than \p CovEnd if not.
|
||||||
virtual Expected<const char *>
|
virtual Expected<const char *> readCoverageHeader(const char *CovBuf,
|
||||||
readCoverageHeader(const char *CovBuf, const char *CovBufEnd,
|
const char *CovBufEnd) = 0;
|
||||||
BinaryCoverageReader::DecompressedData &Decompressed) = 0;
|
|
||||||
|
|
||||||
// Read function records.
|
// Read function records.
|
||||||
//
|
//
|
||||||
@ -505,7 +520,7 @@ struct CovMapFuncRecordReader {
|
|||||||
static Expected<std::unique_ptr<CovMapFuncRecordReader>>
|
static Expected<std::unique_ptr<CovMapFuncRecordReader>>
|
||||||
get(CovMapVersion Version, InstrProfSymtab &P,
|
get(CovMapVersion Version, InstrProfSymtab &P,
|
||||||
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
||||||
std::vector<StringRef> &F);
|
std::vector<std::string> &F);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class for reading coverage mapping function records for a module.
|
// A class for reading coverage mapping function records for a module.
|
||||||
@ -519,7 +534,7 @@ class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
|
|||||||
// in \c Records.
|
// in \c Records.
|
||||||
DenseMap<NameRefType, size_t> FunctionRecords;
|
DenseMap<NameRefType, size_t> FunctionRecords;
|
||||||
InstrProfSymtab &ProfileNames;
|
InstrProfSymtab &ProfileNames;
|
||||||
std::vector<StringRef> &Filenames;
|
std::vector<std::string> &Filenames;
|
||||||
std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records;
|
std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records;
|
||||||
|
|
||||||
// Maps a hash of the filenames in a TU to a \c FileRange. The range
|
// Maps a hash of the filenames in a TU to a \c FileRange. The range
|
||||||
@ -579,14 +594,13 @@ public:
|
|||||||
VersionedCovMapFuncRecordReader(
|
VersionedCovMapFuncRecordReader(
|
||||||
InstrProfSymtab &P,
|
InstrProfSymtab &P,
|
||||||
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
||||||
std::vector<StringRef> &F)
|
std::vector<std::string> &F)
|
||||||
: ProfileNames(P), Filenames(F), Records(R) {}
|
: ProfileNames(P), Filenames(F), Records(R) {}
|
||||||
|
|
||||||
~VersionedCovMapFuncRecordReader() override = default;
|
~VersionedCovMapFuncRecordReader() override = default;
|
||||||
|
|
||||||
Expected<const char *> readCoverageHeader(
|
Expected<const char *> readCoverageHeader(const char *CovBuf,
|
||||||
const char *CovBuf, const char *CovBufEnd,
|
const char *CovBufEnd) override {
|
||||||
BinaryCoverageReader::DecompressedData &Decompressed) override {
|
|
||||||
using namespace support;
|
using namespace support;
|
||||||
|
|
||||||
if (CovBuf + sizeof(CovMapHeader) > CovBufEnd)
|
if (CovBuf + sizeof(CovMapHeader) > CovBufEnd)
|
||||||
@ -615,7 +629,7 @@ public:
|
|||||||
size_t FilenamesBegin = Filenames.size();
|
size_t FilenamesBegin = Filenames.size();
|
||||||
StringRef FilenameRegion(CovBuf, FilenamesSize);
|
StringRef FilenameRegion(CovBuf, FilenamesSize);
|
||||||
RawCoverageFilenamesReader Reader(FilenameRegion, Filenames);
|
RawCoverageFilenamesReader Reader(FilenameRegion, Filenames);
|
||||||
if (auto Err = Reader.read(Version, Decompressed))
|
if (auto Err = Reader.read(Version))
|
||||||
return std::move(Err);
|
return std::move(Err);
|
||||||
CovBuf += FilenamesSize;
|
CovBuf += FilenamesSize;
|
||||||
FilenameRange FileRange(FilenamesBegin, Filenames.size() - FilenamesBegin);
|
FilenameRange FileRange(FilenamesBegin, Filenames.size() - FilenamesBegin);
|
||||||
@ -721,7 +735,7 @@ template <class IntPtrT, support::endianness Endian>
|
|||||||
Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
|
Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
|
||||||
CovMapVersion Version, InstrProfSymtab &P,
|
CovMapVersion Version, InstrProfSymtab &P,
|
||||||
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
|
||||||
std::vector<StringRef> &F) {
|
std::vector<std::string> &F) {
|
||||||
using namespace coverage;
|
using namespace coverage;
|
||||||
|
|
||||||
switch (Version) {
|
switch (Version) {
|
||||||
@ -732,6 +746,7 @@ Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
|
|||||||
case CovMapVersion::Version3:
|
case CovMapVersion::Version3:
|
||||||
case CovMapVersion::Version4:
|
case CovMapVersion::Version4:
|
||||||
case CovMapVersion::Version5:
|
case CovMapVersion::Version5:
|
||||||
|
case CovMapVersion::Version6:
|
||||||
// Decompress the name data.
|
// Decompress the name data.
|
||||||
if (Error E = P.create(P.getNameData()))
|
if (Error E = P.create(P.getNameData()))
|
||||||
return std::move(E);
|
return std::move(E);
|
||||||
@ -747,6 +762,9 @@ Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
|
|||||||
else if (Version == CovMapVersion::Version5)
|
else if (Version == CovMapVersion::Version5)
|
||||||
return std::make_unique<VersionedCovMapFuncRecordReader<
|
return std::make_unique<VersionedCovMapFuncRecordReader<
|
||||||
CovMapVersion::Version5, IntPtrT, Endian>>(P, R, F);
|
CovMapVersion::Version5, IntPtrT, Endian>>(P, R, F);
|
||||||
|
else if (Version == CovMapVersion::Version6)
|
||||||
|
return std::make_unique<VersionedCovMapFuncRecordReader<
|
||||||
|
CovMapVersion::Version6, IntPtrT, Endian>>(P, R, F);
|
||||||
}
|
}
|
||||||
llvm_unreachable("Unsupported version");
|
llvm_unreachable("Unsupported version");
|
||||||
}
|
}
|
||||||
@ -755,8 +773,7 @@ template <typename T, support::endianness Endian>
|
|||||||
static Error readCoverageMappingData(
|
static Error readCoverageMappingData(
|
||||||
InstrProfSymtab &ProfileNames, StringRef CovMap, StringRef FuncRecords,
|
InstrProfSymtab &ProfileNames, StringRef CovMap, StringRef FuncRecords,
|
||||||
std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records,
|
std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records,
|
||||||
std::vector<StringRef> &Filenames,
|
std::vector<std::string> &Filenames) {
|
||||||
BinaryCoverageReader::DecompressedData &Decompressed) {
|
|
||||||
using namespace coverage;
|
using namespace coverage;
|
||||||
|
|
||||||
// Read the records in the coverage data section.
|
// Read the records in the coverage data section.
|
||||||
@ -782,8 +799,7 @@ static Error readCoverageMappingData(
|
|||||||
// header.
|
// header.
|
||||||
//
|
//
|
||||||
// Return a pointer to the next coverage header.
|
// Return a pointer to the next coverage header.
|
||||||
auto NextOrErr =
|
auto NextOrErr = Reader->readCoverageHeader(CovBuf, CovBufEnd);
|
||||||
Reader->readCoverageHeader(CovBuf, CovBufEnd, Decompressed);
|
|
||||||
if (auto E = NextOrErr.takeError())
|
if (auto E = NextOrErr.takeError())
|
||||||
return E;
|
return E;
|
||||||
CovBuf = NextOrErr.get();
|
CovBuf = NextOrErr.get();
|
||||||
@ -810,25 +826,23 @@ BinaryCoverageReader::createCoverageReaderFromBuffer(
|
|||||||
if (Error E =
|
if (Error E =
|
||||||
readCoverageMappingData<uint32_t, support::endianness::little>(
|
readCoverageMappingData<uint32_t, support::endianness::little>(
|
||||||
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
||||||
Reader->MappingRecords, Reader->Filenames,
|
Reader->MappingRecords, Reader->Filenames))
|
||||||
Reader->Decompressed))
|
|
||||||
return std::move(E);
|
return std::move(E);
|
||||||
} else if (BytesInAddress == 4 && Endian == support::endianness::big) {
|
} else if (BytesInAddress == 4 && Endian == support::endianness::big) {
|
||||||
if (Error E = readCoverageMappingData<uint32_t, support::endianness::big>(
|
if (Error E = readCoverageMappingData<uint32_t, support::endianness::big>(
|
||||||
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
||||||
Reader->MappingRecords, Reader->Filenames, Reader->Decompressed))
|
Reader->MappingRecords, Reader->Filenames))
|
||||||
return std::move(E);
|
return std::move(E);
|
||||||
} else if (BytesInAddress == 8 && Endian == support::endianness::little) {
|
} else if (BytesInAddress == 8 && Endian == support::endianness::little) {
|
||||||
if (Error E =
|
if (Error E =
|
||||||
readCoverageMappingData<uint64_t, support::endianness::little>(
|
readCoverageMappingData<uint64_t, support::endianness::little>(
|
||||||
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
||||||
Reader->MappingRecords, Reader->Filenames,
|
Reader->MappingRecords, Reader->Filenames))
|
||||||
Reader->Decompressed))
|
|
||||||
return std::move(E);
|
return std::move(E);
|
||||||
} else if (BytesInAddress == 8 && Endian == support::endianness::big) {
|
} else if (BytesInAddress == 8 && Endian == support::endianness::big) {
|
||||||
if (Error E = readCoverageMappingData<uint64_t, support::endianness::big>(
|
if (Error E = readCoverageMappingData<uint64_t, support::endianness::big>(
|
||||||
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
Reader->ProfileNames, Coverage, FuncRecordsRef,
|
||||||
Reader->MappingRecords, Reader->Filenames, Reader->Decompressed))
|
Reader->MappingRecords, Reader->Filenames))
|
||||||
return std::move(E);
|
return std::move(E);
|
||||||
} else
|
} else
|
||||||
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
||||||
@ -1075,10 +1089,9 @@ Error BinaryCoverageReader::readNextRecord(CoverageMappingRecord &Record) {
|
|||||||
Expressions.clear();
|
Expressions.clear();
|
||||||
MappingRegions.clear();
|
MappingRegions.clear();
|
||||||
auto &R = MappingRecords[CurrentRecord];
|
auto &R = MappingRecords[CurrentRecord];
|
||||||
RawCoverageMappingReader Reader(
|
auto F = makeArrayRef(Filenames).slice(R.FilenamesBegin, R.FilenamesSize);
|
||||||
R.CoverageMapping,
|
RawCoverageMappingReader Reader(R.CoverageMapping, F, FunctionsFilenames,
|
||||||
makeArrayRef(Filenames).slice(R.FilenamesBegin, R.FilenamesSize),
|
Expressions, MappingRegions);
|
||||||
FunctionsFilenames, Expressions, MappingRegions);
|
|
||||||
if (auto Err = Reader.read())
|
if (auto Err = Reader.read())
|
||||||
return Err;
|
return Err;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ using namespace llvm;
|
|||||||
using namespace coverage;
|
using namespace coverage;
|
||||||
|
|
||||||
CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter(
|
CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter(
|
||||||
ArrayRef<StringRef> Filenames)
|
ArrayRef<std::string> Filenames)
|
||||||
: Filenames(Filenames) {
|
: Filenames(Filenames) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
StringSet<> NameSet;
|
StringSet<> NameSet;
|
||||||
|
BIN
test/tools/llvm-cov/Inputs/binary-formats.v6.linux64l
Executable file
BIN
test/tools/llvm-cov/Inputs/binary-formats.v6.linux64l
Executable file
Binary file not shown.
@ -8,5 +8,6 @@ int main(int argc, const char *argv[]) {}
|
|||||||
// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
||||||
// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
||||||
// RUN: llvm-cov show %S/Inputs/binary-formats.v3.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
// RUN: llvm-cov show %S/Inputs/binary-formats.v3.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
||||||
|
// RUN: llvm-cov show %S/Inputs/binary-formats.v6.linux64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
|
||||||
|
|
||||||
// RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
|
// RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
|
||||||
|
@ -129,6 +129,7 @@ struct InputFunctionCoverageData {
|
|||||||
struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
|
struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
|
||||||
bool UseMultipleReaders;
|
bool UseMultipleReaders;
|
||||||
StringMap<unsigned> Files;
|
StringMap<unsigned> Files;
|
||||||
|
std::vector<std::string> Filenames;
|
||||||
std::vector<InputFunctionCoverageData> InputFunctions;
|
std::vector<InputFunctionCoverageData> InputFunctions;
|
||||||
std::vector<OutputFunctionCoverageData> OutputFunctions;
|
std::vector<OutputFunctionCoverageData> OutputFunctions;
|
||||||
|
|
||||||
@ -146,7 +147,7 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
|
|||||||
auto R = Files.find(Name);
|
auto R = Files.find(Name);
|
||||||
if (R != Files.end())
|
if (R != Files.end())
|
||||||
return R->second;
|
return R->second;
|
||||||
unsigned Index = Files.size();
|
unsigned Index = Files.size() + 1;
|
||||||
Files.try_emplace(Name, Index);
|
Files.try_emplace(Name, Index);
|
||||||
return Index;
|
return Index;
|
||||||
}
|
}
|
||||||
@ -200,11 +201,12 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
|
|||||||
|
|
||||||
void readCoverageRegions(const std::string &Coverage,
|
void readCoverageRegions(const std::string &Coverage,
|
||||||
OutputFunctionCoverageData &Data) {
|
OutputFunctionCoverageData &Data) {
|
||||||
SmallVector<StringRef, 8> Filenames(Files.size());
|
Filenames.resize(Files.size() + 1);
|
||||||
for (const auto &E : Files)
|
for (const auto &E : Files)
|
||||||
Filenames[E.getValue()] = E.getKey();
|
Filenames[E.getValue()] = E.getKey().str();
|
||||||
std::vector<CounterExpression> Expressions;
|
std::vector<CounterExpression> Expressions;
|
||||||
RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,
|
ArrayRef<std::string> FilenameRefs = llvm::makeArrayRef(Filenames);
|
||||||
|
RawCoverageMappingReader Reader(Coverage, FilenameRefs, Data.Filenames,
|
||||||
Expressions, Data.Regions);
|
Expressions, Data.Regions);
|
||||||
EXPECT_THAT_ERROR(Reader.read(), Succeeded());
|
EXPECT_THAT_ERROR(Reader.read(), Succeeded());
|
||||||
}
|
}
|
||||||
@ -895,7 +897,7 @@ INSTANTIATE_TEST_CASE_P(ParameterizedCovMapTest, CoverageMappingTest,
|
|||||||
std::pair<bool, bool>({true, true})),);
|
std::pair<bool, bool>({true, true})),);
|
||||||
|
|
||||||
TEST(CoverageMappingTest, filename_roundtrip) {
|
TEST(CoverageMappingTest, filename_roundtrip) {
|
||||||
std::vector<StringRef> Paths({"a", "b", "c", "d", "e"});
|
std::vector<std::string> Paths({"", "a", "b", "c", "d", "e"});
|
||||||
|
|
||||||
for (bool Compress : {false, true}) {
|
for (bool Compress : {false, true}) {
|
||||||
std::string EncodedFilenames;
|
std::string EncodedFilenames;
|
||||||
@ -905,16 +907,12 @@ TEST(CoverageMappingTest, filename_roundtrip) {
|
|||||||
Writer.write(OS, Compress);
|
Writer.write(OS, Compress);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<StringRef> ReadFilenames;
|
std::vector<std::string> ReadFilenames;
|
||||||
RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
|
RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
|
||||||
BinaryCoverageReader::DecompressedData Decompressed;
|
EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion), Succeeded());
|
||||||
EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
|
|
||||||
Succeeded());
|
|
||||||
if (!Compress)
|
|
||||||
ASSERT_EQ(Decompressed.size(), 0U);
|
|
||||||
|
|
||||||
ASSERT_EQ(ReadFilenames.size(), Paths.size());
|
ASSERT_EQ(ReadFilenames.size(), Paths.size());
|
||||||
for (unsigned I = 0; I < Paths.size(); ++I)
|
for (unsigned I = 1; I < Paths.size(); ++I)
|
||||||
ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
|
ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user