67 using namespace support;
72 for (
const auto &K :
P) {
73 FDOStream.
seek(K.Pos);
74 for (
int I = 0;
I < K.N;
I++)
80 FDOStream.
seek(LastPos);
83 std::string &
Data = SOStream.
str();
84 for (
const auto &K :
P) {
85 for (
int I = 0;
I < K.N;
I++) {
87 endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[
I]);
89 (
const char *)&Bytes,
sizeof(
uint64_t));
123 static std::pair<offset_type, offset_type>
125 using namespace support;
133 for (
const auto &ProfileData : *V) {
142 M += ValueProfData::getSize(ProfileData.second);
146 return std::make_pair(
N, M);
154 using namespace support;
157 for (
const auto &ProfileData : *V) {
164 LE.write<
uint64_t>(ProfileData.first);
174 std::unique_ptr<ValueProfData> VDataPtr =
175 ValueProfData::serializeFrom(ProfileData.second);
178 Out.
write((
const char *)VDataPtr.get(), S);
186 bool Sparse,
uint64_t TemporalProfTraceReservoirSize,
187 uint64_t MaxTemporalProfTraceLength,
bool WritePrevVersion,
189 : Sparse(Sparse), MaxTemporalProfTraceLength(MaxTemporalProfTraceLength),
190 TemporalProfTraceReservoirSize(TemporalProfTraceReservoirSize),
192 WritePrevVersion(WritePrevVersion),
193 MemProfVersionRequested(MemProfVersionRequested),
194 MemProfFullSchema(MemProfFullSchema) {}
204 this->Sparse = Sparse;
219 auto Hash =
Other.Hash;
220 Other.accumulateCounts(FuncLevelOverlap.
Test);
221 if (!FunctionData.contains(
Name)) {
229 auto &ProfileDataMap = FunctionData[
Name];
232 std::tie(Where, NewFunc) =
244 Dest.
overlap(
Other, Overlap, FuncLevelOverlap, ValueCutoff);
250 auto &ProfileDataMap = FunctionData[
Name];
254 std::tie(Where, NewFunc) =
259 Warn(make_error<InstrProfError>(E));
266 Dest.
scale(Weight, 1, MapWarn);
269 Dest.
merge(
I, Weight, MapWarn);
277 auto [Iter, Inserted] = MemProfData.
Records.insert({Id,
Record});
289 auto [Iter, Inserted] = MemProfData.
Frames.insert({Id, Frame});
294 if (!Inserted && Iter->second != Frame) {
296 "frame to id mapping mismatch"));
306 auto [Iter, Inserted] = MemProfData.
CallStacks.insert({CSId, CallStack});
311 if (!Inserted && Iter->second != CallStack) {
313 "call stack to id mapping mismatch"));
326 if (TemporalProfTraceStreamSize < TemporalProfTraceReservoirSize) {
328 TemporalProfTraces.push_back(std::move(
Trace));
331 std::uniform_int_distribution<uint64_t> Distribution(
332 0, TemporalProfTraceStreamSize);
333 uint64_t RandomIndex = Distribution(RNG);
334 if (RandomIndex < TemporalProfTraces.size())
335 TemporalProfTraces[RandomIndex] = std::move(
Trace);
337 ++TemporalProfTraceStreamSize;
342 for (
auto &
Trace : SrcTraces)
343 if (
Trace.FunctionNameRefs.
size() > MaxTemporalProfTraceLength)
344 Trace.FunctionNameRefs.resize(MaxTemporalProfTraceLength);
345 llvm::erase_if(SrcTraces, [](
auto &
T) {
return T.FunctionNameRefs.empty(); });
349 (TemporalProfTraceStreamSize > TemporalProfTraceReservoirSize);
350 bool IsSrcSampled = (SrcStreamSize > TemporalProfTraceReservoirSize);
351 if (!IsDestSampled && IsSrcSampled) {
353 std::swap(TemporalProfTraces, SrcTraces);
354 std::swap(TemporalProfTraceStreamSize, SrcStreamSize);
359 for (
auto &
Trace : SrcTraces)
360 addTemporalProfileTrace(std::move(
Trace));
367 std::uniform_int_distribution<uint64_t> Distribution(
368 0, TemporalProfTraceStreamSize);
369 uint64_t RandomIndex = Distribution(RNG);
370 if (RandomIndex < TemporalProfTraces.size())
371 IndicesToReplace.
insert(RandomIndex);
372 ++TemporalProfTraceStreamSize;
382 for (
auto &
I : IPW.FunctionData)
383 for (
auto &Func :
I.getValue())
384 addRecord(
I.getKey(), Func.first, std::move(Func.second), 1, Warn);
386 BinaryIds.reserve(BinaryIds.size() + IPW.BinaryIds.size());
387 for (
auto &
I : IPW.BinaryIds)
391 IPW.TemporalProfTraceStreamSize);
393 MemProfData.
Frames.reserve(IPW.MemProfData.Frames.size());
394 for (
auto &[FrameId, Frame] : IPW.MemProfData.Frames) {
401 MemProfData.
CallStacks.reserve(IPW.MemProfData.CallStacks.size());
402 for (
auto &[CSId, CallStack] : IPW.MemProfData.CallStacks) {
407 MemProfData.
Records.reserve(IPW.MemProfData.Records.size());
408 for (
auto &[GUID,
Record] : IPW.MemProfData.Records) {
413bool InstrProfWriter::shouldEncodeData(
const ProfilingData &PD) {
416 for (
const auto &Func : PD) {
428 using namespace IndexedInstrProf;
439 for (
unsigned I = 0;
I < Res.size();
I++)
447 for (
const auto Id : Schema)
458 *MemProfCallStackIndexes =
nullptr) {
460 MemProfCallStackIndexes);
462 RecordTableGenerator;
463 for (
auto &[GUID,
Record] : MemProfRecordData) {
465 RecordTableGenerator.insert(GUID,
Record, RecordWriter);
468 MemProfRecordData.
clear();
473 return RecordTableGenerator.
Emit(
OS.OS, RecordWriter);
482 for (
auto &[FrameId, Frame] : MemProfFrameData) {
484 FrameTableGenerator.insert(FrameId, Frame);
487 MemProfFrameData.
clear();
489 return FrameTableGenerator.
Emit(
OS.OS);
511 std::vector<std::pair<memprof::FrameId, const memprof::Frame *>> FrameIdOrder;
513 for (
const auto &[Id, Frame] : MemProfFrameData)
514 FrameIdOrder.emplace_back(Id, &Frame);
515 assert(MemProfFrameData.
size() == FrameIdOrder.size());
517 [&](
const std::pair<memprof::FrameId, const memprof::Frame *> &L,
518 const std::pair<memprof::FrameId, const memprof::Frame *> &R) {
519 const auto &SL = FrameHistogram[L.first];
520 const auto &SR = FrameHistogram[R.first];
522 if (SL.Count != SR.Count)
523 return SL.Count > SR.Count;
526 if (SL.PositionSum != SR.PositionSum)
527 return SL.PositionSum < SR.PositionSum;
529 return L.first < R.first;
534 MemProfFrameIndexes.
reserve(FrameIdOrder.size());
535 for (
const auto &[Id,
F] : FrameIdOrder) {
544 MemProfFrameData.
clear();
546 return MemProfFrameIndexes;
552 &MemProfCallStackData) {
554 CallStackTableGenerator;
555 for (
auto &[CSId, CallStack] : MemProfCallStackData)
556 CallStackTableGenerator.insert(CSId, CallStack);
558 MemProfCallStackData.clear();
560 return CallStackTableGenerator.
Emit(
OS.OS);
567 &MemProfCallStackData,
569 &MemProfFrameIndexes,
572 MemProfCallStackIndexes;
575 Builder.
build(std::move(MemProfCallStackData), MemProfFrameIndexes,
582 MemProfCallStackData.clear();
584 return MemProfCallStackIndexes;
614 uint64_t Header[] = {RecordTableOffset, FramePayloadOffset, FrameTableOffset};
615 OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
649 uint64_t Header[] = {RecordTableOffset, FramePayloadOffset, FrameTableOffset};
650 OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
672 bool MemProfFullSchema) {
682 if (MemProfFullSchema)
697 RecordTableOffset, FramePayloadOffset, FrameTableOffset,
698 CallStackPayloadOffset, CallStackTableOffset,
700 OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
720 bool MemProfFullSchema) {
728 if (MemProfFullSchema)
742 OS, MemProfData.
CallStacks, MemProfFrameIndexes, FrameHistogram);
747 &MemProfCallStackIndexes);
750 CallStackPayloadOffset,
754 OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
763 bool MemProfFullSchema) {
764 switch (MemProfVersionRequested) {
775 return make_error<InstrProfError>(
777 formatv(
"MemProf version {} not supported; "
778 "requires version between {} and {}, inclusive",
784 const bool WritePrevVersion,
787 for (
int I = 0;
I < 4;
I++)
791 auto BackPatchStartOffset =
OS.
tell();
798 if (!WritePrevVersion)
801 return BackPatchStartOffset;
805 std::vector<std::string> VTableNameStrs;
807 VTableNameStrs.push_back(VTableName.str());
809 std::string CompressedVTableNames;
810 if (!VTableNameStrs.empty())
813 CompressedVTableNames))
816 const uint64_t CompressedStringLen = CompressedVTableNames.length();
822 for (
auto &c : CompressedVTableNames)
823 OS.writeByte(
static_cast<uint8_t
>(c));
829 for (
uint64_t K = CompressedStringLen;
K < PaddedLength;
K++)
836 using namespace IndexedInstrProf;
837 using namespace support;
848 for (
const auto &
I : FunctionData)
849 if (shouldEncodeData(
I.getValue()))
852 for (
const auto &
I : OrderedData)
853 Generator.insert(
I.first,
I.second);
857 Header.Version = WritePrevVersion
865 Header.Version |= VARIANT_MASK_IR_PROF;
867 Header.Version |= VARIANT_MASK_CSIR_PROF;
868 if (
static_cast<bool>(ProfileKind &
870 Header.Version |= VARIANT_MASK_INSTR_ENTRY;
872 Header.Version |= VARIANT_MASK_BYTE_COVERAGE;
874 Header.Version |= VARIANT_MASK_FUNCTION_ENTRY_ONLY;
876 Header.Version |= VARIANT_MASK_MEMPROF;
878 Header.Version |= VARIANT_MASK_TEMPORAL_PROF;
880 const uint64_t BackPatchStartOffset =
881 writeHeader(Header, WritePrevVersion,
OS);
885 uint32_t SummarySize = Summary::getSize(Summary::NumKinds, NumEntries);
888 for (
unsigned I = 0;
I < SummarySize /
sizeof(
uint64_t);
I++)
893 CSSummaryOffset =
OS.
tell();
894 CSSummarySize = SummarySize /
sizeof(
uint64_t);
895 for (
unsigned I = 0;
I < CSSummarySize;
I++)
905 MemProfSectionStart =
OS.
tell();
906 if (
auto E =
writeMemProf(
OS, MemProfData, MemProfVersionRequested,
923 BinaryIds.erase(
llvm::unique(BinaryIds), BinaryIds.end());
925 for (
const auto &BI : BinaryIds) {
927 BinaryIdsSectionSize +=
sizeof(
uint64_t);
932 OS.
write(BinaryIdsSectionSize);
934 for (
const auto &BI : BinaryIds) {
939 for (
unsigned K = 0;
K < BILen;
K++)
943 for (
unsigned K = 0;
K < PaddingSize;
K++)
949 if (!WritePrevVersion)
950 if (
Error E = writeVTableNames(
OS))
953 uint64_t TemporalProfTracesSectionStart = 0;
955 TemporalProfTracesSectionStart =
OS.
tell();
956 OS.
write(TemporalProfTraces.size());
957 OS.
write(TemporalProfTraceStreamSize);
958 for (
auto &
Trace : TemporalProfTraces) {
961 for (
auto &NameRef :
Trace.FunctionNameRefs)
967 std::unique_ptr<IndexedInstrProf::Summary> TheSummary =
971 std::unique_ptr<ProfileSummary> PS = ISB.getSummary();
976 std::unique_ptr<IndexedInstrProf::Summary> TheCSSummary =
nullptr;
979 std::unique_ptr<ProfileSummary> CSPS = CSISB.getSummary();
985 BinaryIdSectionStart,
986 TemporalProfTracesSectionStart};
987 if (!WritePrevVersion)
988 HeaderOffsets.
push_back(VTableNamesSectionStart);
992 {BackPatchStartOffset, HeaderOffsets.
data(), (int)HeaderOffsets.
size()},
994 {SummaryOffset,
reinterpret_cast<uint64_t *
>(TheSummary.get()),
995 (
int)(SummarySize /
sizeof(
uint64_t))},
996 {CSSummaryOffset,
reinterpret_cast<uint64_t *
>(TheCSSummary.get()),
997 (
int)CSSummarySize}};
999 OS.patch(PatchItems);
1001 for (
const auto &
I : FunctionData)
1002 for (
const auto &
F :
I.getValue())
1012 return writeImpl(POS);
1017 return writeImpl(POS);
1031#define VALUE_PROF_KIND(Enumerator, Value, Descr) #Enumerator,
1036 for (
uint32_t VK = 0; VK <= IPVK_Last; VK++) {
1037 if (VK == IPVK_IndirectCallTarget || VK == IPVK_VTableTarget)
1039 uint32_t NS = Func.getNumValueSites(VK);
1040 for (
uint32_t S = 0; S < NS; S++) {
1042 for (
const auto &V : Func.getValueArrayForSite(VK, S))
1043 if (!SeenValues.
insert(V.Value).second)
1056 OS <<
"# Func Hash:\n" << Hash <<
"\n";
1057 OS <<
"# Num Counters:\n" << Func.Counts.size() <<
"\n";
1058 OS <<
"# Counter Values:\n";
1060 OS << Count <<
"\n";
1062 if (Func.BitmapBytes.size() > 0) {
1063 OS <<
"# Num Bitmap Bytes:\n$" << Func.BitmapBytes.size() <<
"\n";
1064 OS <<
"# Bitmap Byte Values:\n";
1065 for (uint8_t Byte : Func.BitmapBytes) {
1073 uint32_t NumValueKinds = Func.getNumValueKinds();
1074 if (!NumValueKinds) {
1079 OS <<
"# Num Value Kinds:\n" << Func.getNumValueKinds() <<
"\n";
1080 for (
uint32_t VK = 0; VK < IPVK_Last + 1; VK++) {
1081 uint32_t NS = Func.getNumValueSites(VK);
1085 OS <<
"# NumValueSites:\n" << NS <<
"\n";
1086 for (
uint32_t S = 0; S < NS; S++) {
1087 auto VD = Func.getValueArrayForSite(VK, S);
1088 OS << VD.size() <<
"\n";
1089 for (
const auto &V : VD) {
1090 if (VK == IPVK_IndirectCallTarget || VK == IPVK_VTableTarget)
1094 OS << V.Value <<
":" << V.Count <<
"\n";
1105 OS <<
"# CSIR level Instrumentation Flag\n:csir\n";
1107 OS <<
"# IR level Instrumentation Flag\n:ir\n";
1109 if (
static_cast<bool>(ProfileKind &
1111 OS <<
"# Always instrument the function entry block\n:entry_first\n";
1113 OS <<
"# Instrument block coverage\n:single_byte_coverage\n";
1117 using RecordType = std::pair<StringRef, FuncPair>;
1120 for (
const auto &
I : FunctionData) {
1121 if (shouldEncodeData(
I.getValue())) {
1124 for (
const auto &Func :
I.getValue())
1125 OrderedFuncData.
push_back(std::make_pair(
I.getKey(), Func));
1129 for (
const auto &VTableName : VTableNames)
1137 return std::tie(
A.first,
A.second.first) <
1138 std::tie(
B.first,
B.second.first);
1141 for (
const auto &record : OrderedFuncData) {
1143 const FuncPair &Func = record.second;
1147 for (
const auto &record : OrderedFuncData) {
1148 const FuncPair &Func = record.second;
1158 OS <<
":temporal_prof_traces\n";
1159 OS <<
"# Num Temporal Profile Traces:\n" << TemporalProfTraces.
size() <<
"\n";
1160 OS <<
"# Temporal Profile Trace Stream Size:\n"
1161 << TemporalProfTraceStreamSize <<
"\n";
1162 for (
auto &
Trace : TemporalProfTraces) {
1163 OS <<
"# Weight:\n" <<
Trace.Weight <<
"\n";
1164 for (
auto &NameRef :
Trace.FunctionNameRefs)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static Error writeMemProfV0(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData)
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 Error writeMemProf(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData, memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema)
static uint64_t writeMemProfCallStacks(ProfOStream &OS, llvm::MapVector< memprof::CallStackId, llvm::SmallVector< memprof::FrameId > > &MemProfCallStackData)
static Error writeMemProfV1(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData)
static Error writeMemProfV3(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData, bool MemProfFullSchema)
static uint64_t writeMemProfFrames(ProfOStream &OS, llvm::MapVector< memprof::FrameId, memprof::Frame > &MemProfFrameData)
static Error writeMemProfV2(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData, bool MemProfFullSchema)
static void setSummary(IndexedInstrProf::Summary *TheSummary, ProfileSummary &PS)
static const char * ValueProfKindStr[]
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 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 void writeMemProfSchema(ProfOStream &OS, const memprof::MemProfSchema &Schema)
Defines facilities for reading and writing on-disk hash tables.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
const InstrProfWriter::ProfilingData *const data_type_ref
InstrProfSummaryBuilder * SummaryBuilder
llvm::endianness ValueProfDataEndianness
static hash_value_type ComputeHash(key_type_ref K)
InstrProfSummaryBuilder * CSSummaryBuilder
InstrProfRecordWriterTrait()=default
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type N)
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
const InstrProfWriter::ProfilingData *const data_type
void addRecord(const InstrProfRecord &)
A symbol table used for function [IR]PGO name look-up with keys (such as pointers,...
StringRef getFuncOrVarName(uint64_t ValMD5Hash)
Return name of functions or global variables from the name's md5 hash value.
Error addVTableName(StringRef VTableName)
Adds VTableName as a known symbol, and inserts it to a map that tracks all vtable names.
Error addFuncName(StringRef FuncName)
The method name is kept since there are many callers.
StringRef getFuncOrVarNameIfDefined(uint64_t ValMD5Hash)
Just like getFuncOrVarName, except that it will return literal string 'External Symbol' if the functi...
Error write(raw_fd_ostream &OS)
Write the profile to OS.
void addTemporalProfileTraces(SmallVectorImpl< TemporalProfTraceTy > &SrcTraces, uint64_t SrcStreamSize)
Add SrcTraces using reservoir sampling where SrcStreamSize is the total number of temporal profiling ...
void overlapRecord(NamedInstrProfRecord &&Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, const OverlapFuncFilters &FuncFilter)
Error writeText(raw_fd_ostream &OS)
Write the profile in text format to OS.
void addBinaryIds(ArrayRef< llvm::object::BuildID > BIs)
void addMemProfRecord(const GlobalValue::GUID Id, const memprof::IndexedMemProfRecord &Record)
Add a memprof record for a function identified by its Id.
static void writeRecordInText(StringRef Name, uint64_t Hash, const InstrProfRecord &Counters, InstrProfSymtab &Symtab, raw_fd_ostream &OS)
Write Record in text format to OS.
void setValueProfDataEndianness(llvm::endianness Endianness)
bool addMemProfCallStack(const memprof::CallStackId CSId, const llvm::SmallVector< memprof::FrameId > &CallStack, function_ref< void(Error)> Warn)
Add a call stack identified by the hash of the contents of the call stack in CallStack.
void addRecord(NamedInstrProfRecord &&I, uint64_t Weight, function_ref< void(Error)> Warn)
Add function counts for the given function.
InstrProfWriter(bool Sparse=false, uint64_t TemporalProfTraceReservoirSize=0, uint64_t MaxTemporalProfTraceLength=0, bool WritePrevVersion=false, memprof::IndexedVersion MemProfVersionRequested=memprof::Version0, bool MemProfFullSchema=false)
void mergeRecordsFromWriter(InstrProfWriter &&IPW, function_ref< void(Error)> Warn)
Merge existing function counts from the given writer.
void writeTextTemporalProfTraceData(raw_fd_ostream &OS, InstrProfSymtab &Symtab)
Write temporal profile trace data to the header in text format to OS.
std::unique_ptr< MemoryBuffer > writeBuffer()
Write the profile, returning the raw data. For testing.
bool addMemProfFrame(const memprof::FrameId, const memprof::Frame &F, function_ref< void(Error)> Warn)
Add a memprof frame identified by the hash of the contents of the frame in FrameId.
void setOutputSparse(bool Sparse)
Error validateRecord(const InstrProfRecord &Func)
This class implements a map that also provides access to all stored values in a deterministic order.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
Generates an on disk hash table.
offset_type Emit(raw_ostream &Out)
Emit the table to Out, which must not be at offset 0.
void writeByte(uint8_t V)
void patch(ArrayRef< PatchItem > P)
ProfOStream(raw_string_ostream &STR)
support::endian::Writer LE
ProfOStream(raw_fd_ostream &FD)
static const ArrayRef< uint32_t > DefaultCutoffs
A vector of useful cutoff values for detailed summary.
uint64_t getTotalCount() const
uint64_t getMaxCount() const
const SummaryEntryVector & getDetailedSummary()
uint32_t getNumCounts() const
uint64_t getMaxInternalCount() const
uint64_t getMaxFunctionCount() const
uint32_t getNumFunctions() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
StringRef - Represent a constant reference to a string, i.e.
std::pair< iterator, bool > insert(const ValueT &V)
An efficient, type-erasing, non-owning reference to a callable.
void build(llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > &&MemProfCallStackData, const llvm::DenseMap< FrameId, LinearFrameId > &MemProfFrameIndexes, llvm::DenseMap< FrameId, FrameStat > &FrameHistogram)
llvm::DenseMap< CallStackId, LinearCallStackId > takeCallStackPos()
const std::vector< LinearFrameId > & getRadixArray() const
A raw_ostream that writes to a file descriptor.
uint64_t seek(uint64_t off)
Flushes the stream and repositions the underlying file descriptor position to the offset specified fr...
This class implements an extremely fast bulk output stream that can only output to a stream.
uint64_t tell() const
tell - Return the current offset with the file.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
std::unique_ptr< Summary > allocSummary(uint32_t TotalSize)
uint64_t ComputeHash(StringRef K)
constexpr uint64_t MaximumSupportedVersion
MemProfSchema getHotColdSchema()
llvm::DenseMap< FrameId, FrameStat > computeFrameHistogram(llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > &MemProfCallStackData)
constexpr uint64_t MinimumSupportedVersion
MemProfSchema getFullSchema()
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align)
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
void shuffle(Iterator first, Iterator last, RNG &&g)
auto unique(Range &&R, Predicate P)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void sort(IteratorTy Start, IteratorTy End)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Error collectGlobalObjectNameStrings(ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (names of global objects like functions or, virtual tables) NameStrs,...
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
@ FunctionEntryInstrumentation
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
void set(SummaryFieldKind K, uint64_t V)
void setEntry(uint32_t I, const ProfileSummaryEntry &E)
uint64_t NumSummaryFields
uint64_t NumCutoffEntries
Profiling information for a single function.
std::vector< uint64_t > Counts
void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
void overlap(InstrProfRecord &Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff)
Compute the overlap b/w this IntrprofRecord and Other.
void sortValueData()
Sort value profile data (per site) by count.
std::vector< uint8_t > BitmapBytes
void scale(uint64_t N, uint64_t D, function_ref< void(instrprof_error)> Warn)
Scale up profile counts (including value profile data) by a factor of (N / D).
static bool hasCSFlagInHash(uint64_t FuncHash)
const std::string NameFilter
void addOneMismatch(const CountSumOrPercent &MismatchFunc)
CountSumOrPercent Overlap
void addOneUnique(const CountSumOrPercent &UniqueFunc)
An ordered list of functions identified by their NameRef found in INSTR_PROF_DATA.
Function object to check whether the first component of a container supported by std::get (like std::...
llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > CallStacks
llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > Records
llvm::MapVector< FrameId, Frame > Frames
void merge(const IndexedMemProfRecord &Other)
Adapter to write values to a stream in a particular byte order.
void write(ArrayRef< value_type > Val)