#include "llvm/ProfileData/InstrProfWriter.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.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/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdint>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
usingnamespacellvm;
struct PatchItem { … };
namespace llvm {
class ProfOStream { … };
class InstrProfRecordWriterTrait { … };
}
InstrProfWriter::InstrProfWriter(
bool Sparse, uint64_t TemporalProfTraceReservoirSize,
uint64_t MaxTemporalProfTraceLength, bool WritePrevVersion,
memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema)
: … { … }
InstrProfWriter::~InstrProfWriter() { … }
void InstrProfWriter::setValueProfDataEndianness(llvm::endianness Endianness) { … }
void InstrProfWriter::setOutputSparse(bool Sparse) { … }
void InstrProfWriter::addRecord(NamedInstrProfRecord &&I, uint64_t Weight,
function_ref<void(Error)> Warn) { … }
void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other,
OverlapStats &Overlap,
OverlapStats &FuncLevelOverlap,
const OverlapFuncFilters &FuncFilter) { … }
void InstrProfWriter::addRecord(StringRef Name, uint64_t Hash,
InstrProfRecord &&I, uint64_t Weight,
function_ref<void(Error)> Warn) { … }
void InstrProfWriter::addMemProfRecord(
const Function::GUID Id, const memprof::IndexedMemProfRecord &Record) { … }
bool InstrProfWriter::addMemProfFrame(const memprof::FrameId Id,
const memprof::Frame &Frame,
function_ref<void(Error)> Warn) { … }
bool InstrProfWriter::addMemProfCallStack(
const memprof::CallStackId CSId,
const llvm::SmallVector<memprof::FrameId> &CallStack,
function_ref<void(Error)> Warn) { … }
void InstrProfWriter::addBinaryIds(ArrayRef<llvm::object::BuildID> BIs) { … }
void InstrProfWriter::addTemporalProfileTrace(TemporalProfTraceTy Trace) { … }
void InstrProfWriter::addTemporalProfileTraces(
SmallVectorImpl<TemporalProfTraceTy> &SrcTraces, uint64_t SrcStreamSize) { … }
void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
function_ref<void(Error)> Warn) { … }
bool InstrProfWriter::shouldEncodeData(const ProfilingData &PD) { … }
static void setSummary(IndexedInstrProf::Summary *TheSummary,
ProfileSummary &PS) { … }
static void writeMemProfSchema(ProfOStream &OS,
const memprof::MemProfSchema &Schema) { … }
static uint64_t writeMemProfRecords(
ProfOStream &OS,
llvm::MapVector<GlobalValue::GUID, memprof::IndexedMemProfRecord>
&MemProfRecordData,
memprof::MemProfSchema *Schema, memprof::IndexedVersion Version,
llvm::DenseMap<memprof::CallStackId, memprof::LinearCallStackId>
*MemProfCallStackIndexes = nullptr) { … }
static uint64_t writeMemProfFrames(
ProfOStream &OS,
llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData) { … }
static llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId>
writeMemProfFrameArray(
ProfOStream &OS,
llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData,
llvm::DenseMap<memprof::FrameId, memprof::FrameStat> &FrameHistogram) { … }
static uint64_t writeMemProfCallStacks(
ProfOStream &OS,
llvm::MapVector<memprof::CallStackId, llvm::SmallVector<memprof::FrameId>>
&MemProfCallStackData) { … }
static llvm::DenseMap<memprof::CallStackId, memprof::LinearCallStackId>
writeMemProfCallStackArray(
ProfOStream &OS,
llvm::MapVector<memprof::CallStackId, llvm::SmallVector<memprof::FrameId>>
&MemProfCallStackData,
llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId>
&MemProfFrameIndexes,
llvm::DenseMap<memprof::FrameId, memprof::FrameStat> &FrameHistogram) { … }
static Error writeMemProfV0(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData) { … }
static Error writeMemProfV1(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData) { … }
static Error writeMemProfV2(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData,
bool MemProfFullSchema) { … }
static Error writeMemProfV3(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData,
bool MemProfFullSchema) { … }
static Error writeMemProf(ProfOStream &OS,
memprof::IndexedMemProfData &MemProfData,
memprof::IndexedVersion MemProfVersionRequested,
bool MemProfFullSchema) { … }
uint64_t InstrProfWriter::writeHeader(const IndexedInstrProf::Header &Header,
const bool WritePrevVersion,
ProfOStream &OS) { … }
Error InstrProfWriter::writeVTableNames(ProfOStream &OS) { … }
Error InstrProfWriter::writeImpl(ProfOStream &OS) { … }
Error InstrProfWriter::write(raw_fd_ostream &OS) { … }
Error InstrProfWriter::write(raw_string_ostream &OS) { … }
std::unique_ptr<MemoryBuffer> InstrProfWriter::writeBuffer() { … }
static const char *ValueProfKindStr[] = …;
Error InstrProfWriter::validateRecord(const InstrProfRecord &Func) { … }
void InstrProfWriter::writeRecordInText(StringRef Name, uint64_t Hash,
const InstrProfRecord &Func,
InstrProfSymtab &Symtab,
raw_fd_ostream &OS) { … }
Error InstrProfWriter::writeText(raw_fd_ostream &OS) { … }
void InstrProfWriter::writeTextTemporalProfTraceData(raw_fd_ostream &OS,
InstrProfSymtab &Symtab) { … }