#include "llvm/ProfileData/SampleProfWriter.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/ProfileData/SampleProf.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <memory>
#include <set>
#include <system_error>
#include <utility>
#include <vector>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespacesampleprof;
namespace llvm {
namespace support {
namespace endian {
namespace {
struct SeekableWriter { … };
}
}
}
}
DefaultFunctionPruningStrategy::DefaultFunctionPruningStrategy(
SampleProfileMap &ProfileMap, size_t OutputSizeLimit)
: … { … }
void DefaultFunctionPruningStrategy::Erase(size_t CurrentOutputSize) { … }
std::error_code SampleProfileWriter::writeWithSizeLimitInternal(
SampleProfileMap &ProfileMap, size_t OutputSizeLimit,
FunctionPruningStrategy *Strategy) { … }
std::error_code
SampleProfileWriter::writeFuncProfiles(const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriter::write(const SampleProfileMap &ProfileMap) { … }
uint64_t
SampleProfileWriterExtBinaryBase::markSectionStart(SecType Type,
uint32_t LayoutIdx) { … }
std::error_code SampleProfileWriterExtBinaryBase::compressAndOutput() { … }
std::error_code SampleProfileWriterExtBinaryBase::addNewSection(
SecType Type, uint32_t LayoutIdx, uint64_t SectionStart) { … }
std::error_code
SampleProfileWriterExtBinaryBase::write(const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterExtBinaryBase::writeContextIdx(
const SampleContext &Context) { … }
std::error_code
SampleProfileWriterExtBinaryBase::writeCSNameIdx(const SampleContext &Context) { … }
std::error_code
SampleProfileWriterExtBinaryBase::writeSample(const FunctionSamples &S) { … }
std::error_code SampleProfileWriterExtBinaryBase::writeFuncOffsetTable() { … }
std::error_code SampleProfileWriterExtBinaryBase::writeFuncMetadata(
const FunctionSamples &FunctionProfile) { … }
std::error_code SampleProfileWriterExtBinaryBase::writeFuncMetadata(
const SampleProfileMap &Profiles) { … }
std::error_code SampleProfileWriterExtBinaryBase::writeNameTable() { … }
std::error_code SampleProfileWriterExtBinaryBase::writeNameTableSection(
const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterExtBinaryBase::writeCSNameTableSection() { … }
std::error_code
SampleProfileWriterExtBinaryBase::writeProfileSymbolListSection() { … }
std::error_code SampleProfileWriterExtBinaryBase::writeOneSection(
SecType Type, uint32_t LayoutIdx, const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterExtBinary::writeDefaultLayout(
const SampleProfileMap &ProfileMap) { … }
static void splitProfileMapToTwo(const SampleProfileMap &ProfileMap,
SampleProfileMap &ContextProfileMap,
SampleProfileMap &NoContextProfileMap) { … }
std::error_code SampleProfileWriterExtBinary::writeCtxSplitLayout(
const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterExtBinary::writeSections(
const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterText::writeSample(const FunctionSamples &S) { … }
std::error_code
SampleProfileWriterBinary::writeContextIdx(const SampleContext &Context) { … }
std::error_code SampleProfileWriterBinary::writeNameIdx(FunctionId FName) { … }
void SampleProfileWriterBinary::addName(FunctionId FName) { … }
void SampleProfileWriterBinary::addContext(const SampleContext &Context) { … }
void SampleProfileWriterBinary::addNames(const FunctionSamples &S) { … }
void SampleProfileWriterExtBinaryBase::addContext(
const SampleContext &Context) { … }
void SampleProfileWriterBinary::stablizeNameTable(
MapVector<FunctionId, uint32_t> &NameTable, std::set<FunctionId> &V) { … }
std::error_code SampleProfileWriterBinary::writeNameTable() { … }
std::error_code
SampleProfileWriterBinary::writeMagicIdent(SampleProfileFormat Format) { … }
std::error_code
SampleProfileWriterBinary::writeHeader(const SampleProfileMap &ProfileMap) { … }
void SampleProfileWriterExtBinaryBase::setToCompressAllSections() { … }
void SampleProfileWriterExtBinaryBase::setToCompressSection(SecType Type) { … }
void SampleProfileWriterExtBinaryBase::allocSecHdrTable() { … }
std::error_code SampleProfileWriterExtBinaryBase::writeSecHdrTable() { … }
std::error_code SampleProfileWriterExtBinaryBase::writeHeader(
const SampleProfileMap &ProfileMap) { … }
std::error_code SampleProfileWriterBinary::writeSummary() { … }
std::error_code SampleProfileWriterBinary::writeBody(const FunctionSamples &S) { … }
std::error_code
SampleProfileWriterBinary::writeSample(const FunctionSamples &S) { … }
ErrorOr<std::unique_ptr<SampleProfileWriter>>
SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) { … }
ErrorOr<std::unique_ptr<SampleProfileWriter>>
SampleProfileWriter::create(std::unique_ptr<raw_ostream> &OS,
SampleProfileFormat Format) { … }
void SampleProfileWriter::computeSummary(const SampleProfileMap &ProfileMap) { … }