#include "llvm/ProfileData/Coverage/CoverageMappingReader.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include <vector>
usingnamespacellvm;
usingnamespacecoverage;
usingnamespaceobject;
#define DEBUG_TYPE …
STATISTIC(CovMapNumRecords, "The # of coverage function records");
STATISTIC(CovMapNumUsedRecords, "The # of used coverage function records");
void CoverageMappingIterator::increment() { … }
Error RawCoverageReader::readULEB128(uint64_t &Result) { … }
Error RawCoverageReader::readIntMax(uint64_t &Result, uint64_t MaxPlus1) { … }
Error RawCoverageReader::readSize(uint64_t &Result) { … }
Error RawCoverageReader::readString(StringRef &Result) { … }
Error RawCoverageFilenamesReader::read(CovMapVersion Version) { … }
Error RawCoverageFilenamesReader::readUncompressed(CovMapVersion Version,
uint64_t NumFilenames) { … }
Error RawCoverageMappingReader::decodeCounter(unsigned Value, Counter &C) { … }
Error RawCoverageMappingReader::readCounter(Counter &C) { … }
static const unsigned EncodingExpansionRegionBit = …;
Error RawCoverageMappingReader::readMappingRegionsSubArray(
std::vector<CounterMappingRegion> &MappingRegions, unsigned InferredFileID,
size_t NumFileIDs) { … }
Error RawCoverageMappingReader::read() { … }
Expected<bool> RawCoverageMappingDummyChecker::isDummy() { … }
Error InstrProfSymtab::create(SectionRef &Section) { … }
StringRef InstrProfSymtab::getFuncName(uint64_t Pointer, size_t Size) { … }
static Expected<bool> isCoverageMappingDummy(uint64_t Hash, StringRef Mapping) { … }
struct FilenameRange { … };
namespace {
struct CovMapFuncRecordReader { … };
template <CovMapVersion Version, class IntPtrT, llvm::endianness Endian>
class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader { … };
}
template <class IntPtrT, llvm::endianness Endian>
Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
CovMapVersion Version, InstrProfSymtab &P,
std::vector<BinaryCoverageReader::ProfileMappingRecord> &R, StringRef D,
std::vector<std::string> &F) { … }
template <typename T, llvm::endianness Endian>
static Error readCoverageMappingData(
InstrProfSymtab &ProfileNames, StringRef CovMap, StringRef FuncRecords,
std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records,
StringRef CompilationDir, std::vector<std::string> &Filenames) { … }
Expected<std::unique_ptr<BinaryCoverageReader>>
BinaryCoverageReader::createCoverageReaderFromBuffer(
StringRef Coverage, FuncRecordsStorage &&FuncRecords,
std::unique_ptr<InstrProfSymtab> ProfileNamesPtr, uint8_t BytesInAddress,
llvm::endianness Endian, StringRef CompilationDir) { … }
static Expected<std::unique_ptr<BinaryCoverageReader>>
loadTestingFormat(StringRef Data, StringRef CompilationDir) { … }
static Expected<std::vector<SectionRef>>
lookupSections(ObjectFile &OF, InstrProfSectKind IPSK) { … }
static Expected<std::unique_ptr<BinaryCoverageReader>>
loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
StringRef CompilationDir = "",
object::BuildIDRef *BinaryID = nullptr) { … }
static bool isArchSpecifierInvalidOrMissing(Binary *Bin, StringRef Arch) { … }
Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
BinaryCoverageReader::create(
MemoryBufferRef ObjectBuffer, StringRef Arch,
SmallVectorImpl<std::unique_ptr<MemoryBuffer>> &ObjectFileBuffers,
StringRef CompilationDir, SmallVectorImpl<object::BuildIDRef> *BinaryIDs) { … }
Error BinaryCoverageReader::readNextRecord(CoverageMappingRecord &Record) { … }