#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ProfileSummary.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ProfileData/MemProf.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/ProfileData/SymbolRemappingReader.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
#include <system_error>
#include <utility>
#include <vector>
usingnamespacellvm;
static InstrProfKind getProfileKindFromVersion(uint64_t Version) { … }
static Expected<std::unique_ptr<MemoryBuffer>>
setupMemoryBuffer(const Twine &Filename, vfs::FileSystem &FS) { … }
static Error initializeReader(InstrProfReader &Reader) { … }
static Error
readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
ArrayRef<uint8_t> BinaryIdsBuffer,
std::vector<llvm::object::BuildID> &BinaryIds,
const llvm::endianness Endian) { … }
static void printBinaryIdsInternal(raw_ostream &OS,
ArrayRef<llvm::object::BuildID> BinaryIds) { … }
Expected<std::unique_ptr<InstrProfReader>> InstrProfReader::create(
const Twine &Path, vfs::FileSystem &FS,
const InstrProfCorrelator *Correlator,
const object::BuildIDFetcher *BIDFetcher,
const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind,
std::function<void(Error)> Warn) { … }
Expected<std::unique_ptr<InstrProfReader>> InstrProfReader::create(
std::unique_ptr<MemoryBuffer> Buffer, const InstrProfCorrelator *Correlator,
const object::BuildIDFetcher *BIDFetcher,
const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind,
std::function<void(Error)> Warn) { … }
Expected<std::unique_ptr<IndexedInstrProfReader>>
IndexedInstrProfReader::create(const Twine &Path, vfs::FileSystem &FS,
const Twine &RemappingPath) { … }
Expected<std::unique_ptr<IndexedInstrProfReader>>
IndexedInstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer,
std::unique_ptr<MemoryBuffer> RemappingBuffer) { … }
bool TextInstrProfReader::hasFormat(const MemoryBuffer &Buffer) { … }
Error TextInstrProfReader::readHeader() { … }
Error TextInstrProfReader::readTemporalProfTraceData() { … }
Error
TextInstrProfReader::readValueProfileData(InstrProfRecord &Record) { … }
Error TextInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) { … }
template <class IntPtrT>
InstrProfKind RawInstrProfReader<IntPtrT>::getProfileKind() const { … }
template <class IntPtrT>
SmallVector<TemporalProfTraceTy> &
RawInstrProfReader<IntPtrT>::getTemporalProfTraces(
std::optional<uint64_t> Weight) { … }
template <class IntPtrT>
bool RawInstrProfReader<IntPtrT>::hasFormat(const MemoryBuffer &DataBuffer) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readHeader() { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readNextHeader(const char *CurrentPos) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readHeader(
const RawInstrProf::Header &Header) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readName(NamedInstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readFuncHash(NamedInstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readRawCounts(
InstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readRawBitmapBytes(InstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readValueProfilingData(
InstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readNextRecord(NamedInstrProfRecord &Record) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::readBinaryIds(
std::vector<llvm::object::BuildID> &BinaryIds) { … }
template <class IntPtrT>
Error RawInstrProfReader<IntPtrT>::printBinaryIds(raw_ostream &OS) { … }
namespace llvm {
template class RawInstrProfReader<uint32_t>;
template class RawInstrProfReader<uint64_t>;
}
InstrProfLookupTrait::hash_value_type
InstrProfLookupTrait::ComputeHash(StringRef K) { … }
data_type;
offset_type;
bool InstrProfLookupTrait::readValueProfilingData(
const unsigned char *&D, const unsigned char *const End) { … }
data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
offset_type N) { … }
template <typename HashTableImpl>
Error InstrProfReaderIndex<HashTableImpl>::getRecords(
StringRef FuncName, ArrayRef<NamedInstrProfRecord> &Data) { … }
template <typename HashTableImpl>
Error InstrProfReaderIndex<HashTableImpl>::getRecords(
ArrayRef<NamedInstrProfRecord> &Data) { … }
template <typename HashTableImpl>
InstrProfReaderIndex<HashTableImpl>::InstrProfReaderIndex(
const unsigned char *Buckets, const unsigned char *const Payload,
const unsigned char *const Base, IndexedInstrProf::HashT HashType,
uint64_t Version) { … }
template <typename HashTableImpl>
InstrProfKind InstrProfReaderIndex<HashTableImpl>::getProfileKind() const { … }
namespace {
class InstrProfReaderNullRemapper : public InstrProfReaderRemapper { … };
}
template <typename HashTableImpl>
class llvm::InstrProfReaderItaniumRemapper
: public InstrProfReaderRemapper { … };
bool IndexedInstrProfReader::hasFormat(const MemoryBuffer &DataBuffer) { … }
const unsigned char *
IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
const unsigned char *Cur, bool UseCS) { … }
Error IndexedMemProfReader::deserializeV012(const unsigned char *Start,
const unsigned char *Ptr,
uint64_t FirstWord) { … }
Error IndexedMemProfReader::deserializeV3(const unsigned char *Start,
const unsigned char *Ptr) { … }
Error IndexedMemProfReader::deserialize(const unsigned char *Start,
uint64_t MemProfOffset) { … }
Error IndexedInstrProfReader::readHeader() { … }
InstrProfSymtab &IndexedInstrProfReader::getSymtab() { … }
Expected<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
StringRef FuncName, uint64_t FuncHash, StringRef DeprecatedFuncName,
uint64_t *MismatchedFuncSum) { … }
static Expected<memprof::MemProfRecord>
getMemProfRecordV0(const memprof::IndexedMemProfRecord &IndexedRecord,
MemProfFrameHashTable &MemProfFrameTable) { … }
static Expected<memprof::MemProfRecord>
getMemProfRecordV2(const memprof::IndexedMemProfRecord &IndexedRecord,
MemProfFrameHashTable &MemProfFrameTable,
MemProfCallStackHashTable &MemProfCallStackTable) { … }
static Expected<memprof::MemProfRecord>
getMemProfRecordV3(const memprof::IndexedMemProfRecord &IndexedRecord,
const unsigned char *FrameBase,
const unsigned char *CallStackBase) { … }
Expected<memprof::MemProfRecord>
IndexedMemProfReader::getMemProfRecord(const uint64_t FuncNameHash) const { … }
Error IndexedInstrProfReader::getFunctionCounts(StringRef FuncName,
uint64_t FuncHash,
std::vector<uint64_t> &Counts) { … }
Error IndexedInstrProfReader::getFunctionBitmap(StringRef FuncName,
uint64_t FuncHash,
BitVector &Bitmap) { … }
Error IndexedInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) { … }
Error IndexedInstrProfReader::readBinaryIds(
std::vector<llvm::object::BuildID> &BinaryIds) { … }
Error IndexedInstrProfReader::printBinaryIds(raw_ostream &OS) { … }
void InstrProfReader::accumulateCounts(CountSumOrPercent &Sum, bool IsCS) { … }