35#include <system_error>
45 if (Version & VARIANT_MASK_IR_PROF) {
46 ProfileKind |= InstrProfKind::IRInstrumentation;
48 if (Version & VARIANT_MASK_CSIR_PROF) {
49 ProfileKind |= InstrProfKind::ContextSensitive;
51 if (Version & VARIANT_MASK_INSTR_ENTRY) {
52 ProfileKind |= InstrProfKind::FunctionEntryInstrumentation;
54 if (Version & VARIANT_MASK_BYTE_COVERAGE) {
55 ProfileKind |= InstrProfKind::SingleByteCoverage;
57 if (Version & VARIANT_MASK_FUNCTION_ENTRY_ONLY) {
58 ProfileKind |= InstrProfKind::FunctionEntryOnly;
60 if (Version & VARIANT_MASK_MEMPROF) {
61 ProfileKind |= InstrProfKind::MemProf;
69 : FS.getBufferForFile(Filename);
70 if (std::error_code EC = BufferOrErr.getError())
72 return std::move(BufferOrErr.get());
90 const uint8_t *BinaryIdsStart,
91 std::vector<llvm::object::BuildID> &BinaryIds,
93 using namespace support;
95 if (BinaryIdsSize == 0)
98 const uint8_t *BI = BinaryIdsStart;
99 const uint8_t *BIEnd = BinaryIdsStart + BinaryIdsSize;
101 reinterpret_cast<const uint8_t *
>(DataBuffer.
getBufferEnd());
104 size_t Remaining = BIEnd - BI;
107 return make_error<InstrProfError>(
108 instrprof_error::malformed,
109 "not enough data to read binary id length");
112 if (Endian == little)
113 BILen = endian::readNext<uint64_t, little, unaligned>(BI);
115 BILen = endian::readNext<uint64_t, big, unaligned>(BI);
118 return make_error<InstrProfError>(instrprof_error::malformed,
119 "binary id length is 0");
121 Remaining = BIEnd - BI;
124 return make_error<InstrProfError>(
125 instrprof_error::malformed,
"not enough data to read binary id data");
133 return make_error<InstrProfError>(
134 instrprof_error::malformed,
135 "binary id section is greater than buffer size");
144 const uint8_t *BinaryIdsStart,
146 if (BinaryIdsSize == 0)
149 std::vector<llvm::object::BuildID> BinaryIds;
154 OS <<
"Binary IDs: \n";
155 for (
auto BI : BinaryIds) {
169 if (
Error E = BufferOrError.takeError())
177 if (Buffer->getBufferSize() == 0)
180 std::unique_ptr<InstrProfReader> Result;
197 return std::move(Result);
202 const Twine &RemappingPath) {
205 if (
Error E = BufferOrError.takeError())
209 std::unique_ptr<MemoryBuffer> RemappingBuffer;
210 std::string RemappingPathStr = RemappingPath.
str();
211 if (!RemappingPathStr.empty()) {
213 if (
Error E = RemappingBufferOrError.takeError())
215 RemappingBuffer = std::move(RemappingBufferOrError.get());
219 std::move(RemappingBuffer));
224 std::unique_ptr<MemoryBuffer> RemappingBuffer) {
228 auto Result = std::make_unique<IndexedInstrProfReader>(
229 std::move(Buffer), std::move(RemappingBuffer));
235 return std::move(Result);
245 [](
char c) { return isPrint(c) || isSpace(c); });
256 if (Str.equals_insensitive(
"ir"))
258 else if (Str.equals_insensitive(
"fe"))
260 else if (Str.equals_insensitive(
"csir")) {
263 }
else if (Str.equals_insensitive(
"entry_first"))
265 else if (Str.equals_insensitive(
"not_entry_first"))
277#define CHECK_LINE_END(Line) \
278 if (Line.is_at_end()) \
279 return error(instrprof_error::truncated);
280#define READ_NUM(Str, Dst) \
281 if ((Str).getAsInteger(10, (Dst))) \
282 return error(instrprof_error::malformed);
283#define VP_READ_ADVANCE(Val) \
284 CHECK_LINE_END(Line); \
286 READ_NUM((*Line), (Val)); \
297 if (NumValueKinds == 0 || NumValueKinds > IPVK_Last + 1)
299 "number of value kinds is invalid");
302 for (
uint32_t VK = 0; VK < NumValueKinds; VK++) {
304 if (ValueKind > IPVK_Last)
311 Record.reserveSites(VK, NumValueSites);
312 for (
uint32_t S = 0; S < NumValueSites; S++) {
315 std::vector<InstrProfValueData> CurrentValues;
316 for (
uint32_t V = 0; V < NumValueData; V++) {
318 std::pair<StringRef, StringRef> VD = Line->
rsplit(
':');
320 if (ValueKind == IPVK_IndirectCallTarget) {
332 CurrentValues.push_back({
Value, TakenCount});
335 Record.addValueData(ValueKind, S, CurrentValues.data(), NumValueData,
343#undef VP_READ_ADVANCE
358 return error(std::move(
E));
363 if ((Line++)->getAsInteger(0,
Record.Hash))
365 "function hash is not a valid integer");
371 if ((Line++)->getAsInteger(10, NumCounters))
373 "number of counters is not a valid integer");
374 if (NumCounters == 0)
379 Record.Counts.reserve(NumCounters);
384 if ((Line++)->getAsInteger(10, Count))
386 Record.Counts.push_back(Count);
391 return error(std::move(
E));
396template <
class IntPtrT>
401template <
class IntPtrT>
407 return RawInstrProf::getMagic<IntPtrT>() == Magic ||
411template <
class IntPtrT>
413 if (!hasFormat(*DataBuffer))
418 DataBuffer->getBufferStart());
419 ShouldSwapBytes = Header->Magic != RawInstrProf::getMagic<IntPtrT>();
420 return readHeader(*Header);
423template <
class IntPtrT>
425 const char *End = DataBuffer->getBufferEnd();
427 while (CurrentPos != End && *CurrentPos == 0)
430 if (CurrentPos == End)
436 "not enough space for another header");
438 if (
reinterpret_cast<size_t>(CurrentPos) %
alignof(
uint64_t))
440 "insufficient padding");
443 if (Magic != swap(RawInstrProf::getMagic<IntPtrT>()))
448 return readHeader(*Header);
451template <
class IntPtrT>
454 return error(std::move(
E));
456 const IntPtrT FPtr = swap(
I->FunctionPointer);
464template <
class IntPtrT>
470 if (useDebugInfoCorrelate() && !Correlator)
472 if (!useDebugInfoCorrelate() && Correlator)
475 BinaryIdsSize =
swap(Header.BinaryIdsSize);
476 if (BinaryIdsSize %
sizeof(
uint64_t))
479 CountersDelta =
swap(Header.CountersDelta);
480 NamesDelta =
swap(Header.NamesDelta);
481 auto NumData =
swap(Header.DataSize);
482 auto PaddingBytesBeforeCounters =
swap(Header.PaddingBytesBeforeCounters);
483 auto CountersSize =
swap(Header.CountersSize) * getCounterTypeSize();
484 auto PaddingBytesAfterCounters =
swap(Header.PaddingBytesAfterCounters);
485 auto NamesSize =
swap(Header.NamesSize);
486 ValueKindLast =
swap(Header.ValueKindLast);
489 auto PaddingSize = getNumPaddingBytes(NamesSize);
493 ptrdiff_t CountersOffset = DataOffset + DataSize + PaddingBytesBeforeCounters;
495 CountersOffset + CountersSize + PaddingBytesAfterCounters;
496 ptrdiff_t ValueDataOffset = NamesOffset + NamesSize + PaddingSize;
498 auto *Start =
reinterpret_cast<const char *
>(&Header);
499 if (Start + ValueDataOffset > DataBuffer->getBufferEnd())
505 assert(DataSize == 0 && NamesSize == 0);
506 assert(CountersDelta == 0 && NamesDelta == 0);
507 Data = Correlator->getDataPointer();
508 DataEnd =
Data + Correlator->getDataSize();
509 NamesStart = Correlator->getNamesPointer();
510 NamesEnd = NamesStart + Correlator->getNamesSize();
514 DataEnd =
Data + NumData;
515 NamesStart = Start + NamesOffset;
516 NamesEnd = NamesStart + NamesSize;
522 CountersStart = Start + CountersOffset;
523 CountersEnd = CountersStart + CountersSize;
524 ValueDataStart =
reinterpret_cast<const uint8_t *
>(Start + ValueDataOffset);
526 const uint8_t *BufferEnd = (
const uint8_t *)DataBuffer->getBufferEnd();
527 if (BinaryIdsStart + BinaryIdsSize > BufferEnd)
530 std::unique_ptr<InstrProfSymtab> NewSymtab = std::make_unique<InstrProfSymtab>();
531 if (
Error E = createSymtab(*NewSymtab))
534 Symtab = std::move(NewSymtab);
538template <
class IntPtrT>
544template <
class IntPtrT>
550template <
class IntPtrT>
554 if (NumCounters == 0)
558 if (CounterBaseOffset < 0)
561 (
"counter offset " +
Twine(CounterBaseOffset) +
" is negative").str());
563 if (CounterBaseOffset >= CountersEnd - CountersStart)
565 (
"counter offset " +
Twine(CounterBaseOffset) +
566 " is greater than the maximum counter offset " +
567 Twine(CountersEnd - CountersStart - 1))
571 (CountersEnd - (CountersStart + CounterBaseOffset)) /
572 getCounterTypeSize();
573 if (NumCounters > MaxNumCounters)
575 (
"number of counters " +
Twine(NumCounters) +
576 " is greater than the maximum number of counters " +
577 Twine(MaxNumCounters))
581 Record.Counts.reserve(NumCounters);
584 CountersStart + CounterBaseOffset +
I * getCounterTypeSize();
585 if (hasSingleByteCoverage()) {
587 Record.Counts.push_back(*
Ptr == 0 ? 1 : 0);
589 const auto *CounterValue =
reinterpret_cast<const uint64_t *
>(
Ptr);
597template <
class IntPtrT>
601 CurValueDataSize = 0;
605 NumValueKinds += (
Data->NumValueSites[
I] != 0);
611 ValueProfData::getValueProfData(
612 ValueDataStart, (
const unsigned char *)DataBuffer->getBufferEnd(),
613 getDataEndianness());
621 VDataPtrOrErr.
get()->deserializeTo(
Record, Symtab.get());
622 CurValueDataSize = VDataPtrOrErr.
get()->getSize();
626template <
class IntPtrT>
632 if (
Error E = readNextHeader(getNextHeaderPos()))
633 return error(std::move(
E));
637 return error(std::move(
E));
641 return error(std::move(
E));
645 return error(std::move(
E));
649 return error(std::move(
E));
656template <
class IntPtrT>
658 std::vector<llvm::object::BuildID> &BinaryIds) {
660 BinaryIds, getDataEndianness());
663template <
class IntPtrT>
666 getDataEndianness());
685 const unsigned char *&
D,
const unsigned char *
const End) {
687 ValueProfData::getValueProfData(
D, End, ValueProfDataEndianness);
692 VDataPtrOrErr.
get()->deserializeTo(DataBuffer.back(),
nullptr);
693 D += VDataPtrOrErr.
get()->TotalSize;
700 using namespace support;
707 std::vector<uint64_t> CounterBuffer;
709 const unsigned char *End =
D +
N;
714 uint64_t Hash = endian::readNext<uint64_t, little, unaligned>(
D);
722 CountsSize = endian::readNext<uint64_t, little, unaligned>(
D);
725 if (
D + CountsSize *
sizeof(
uint64_t) > End)
728 CounterBuffer.clear();
729 CounterBuffer.reserve(CountsSize);
730 for (
uint64_t J = 0; J < CountsSize; ++J)
731 CounterBuffer.push_back(endian::readNext<uint64_t, little, unaligned>(
D));
733 DataBuffer.emplace_back(K, Hash, std::move(CounterBuffer));
745template <
typename HashTableImpl>
748 auto Iter = HashTable->find(FuncName);
749 if (Iter == HashTable->end())
755 "profile data is empty");
760template <
typename HashTableImpl>
766 Data = *RecordIterator;
770 "profile data is empty");
775template <
typename HashTableImpl>
777 const unsigned char *Buckets,
const unsigned char *
const Payload,
780 FormatVersion = Version;
781 HashTable.reset(HashTableImpl::Create(
782 Buckets, Payload,
Base,
783 typename HashTableImpl::InfoType(HashType, Version)));
784 RecordIterator = HashTable->data_begin();
787template <
typename HashTableImpl>
799 : Underlying(Underlying) {}
803 return Underlying.getRecords(FuncName,
Data);
809template <
typename HashTableImpl>
814 std::unique_ptr<MemoryBuffer> RemapBuffer,
816 : RemapBuffer(
std::
move(RemapBuffer)), Underlying(Underlying) {
826 Parts = Parts.second.split(
':');
827 if (Parts.first.startswith(
"_Z"))
829 if (Parts.second.empty())
850 if (
auto Key = Remappings.
insert(RealName)) {
854 MappedNames.insert({Key, RealName});
863 if (
auto Key = Remappings.
lookup(RealName)) {
864 StringRef Remapped = MappedNames.lookup(Key);
865 if (!Remapped.
empty()) {
867 RealName.
end() == FuncName.
end())
873 Error E = Underlying.getRecords(Reconstituted,
Data);
880 std::move(
E), [](std::unique_ptr<InstrProfError> Err) {
883 :
Error(std::move(Err));
889 return Underlying.getRecords(FuncName,
Data);
895 std::unique_ptr<MemoryBuffer> RemapBuffer;
911 using namespace support;
916 endian::read<uint64_t, little, aligned>(DataBuffer.
getBufferStart());
923 const unsigned char *Cur,
bool UseCS) {
924 using namespace IndexedInstrProf;
925 using namespace support;
936 std::unique_ptr<IndexedInstrProf::Summary> SummaryData =
941 for (
unsigned I = 0;
I < SummarySize /
sizeof(
uint64_t);
I++)
942 Dst[
I] = endian::byte_swap<uint64_t, little>(Src[
I]);
945 for (
unsigned I = 0;
I < SummaryData->NumCutoffEntries;
I++) {
950 std::unique_ptr<llvm::ProfileSummary> &Summary =
951 UseCS ? this->CS_Summary : this->Summary;
954 Summary = std::make_unique<ProfileSummary>(
956 DetailedSummary, SummaryData->get(Summary::TotalBlockCount),
957 SummaryData->get(Summary::MaxBlockCount),
958 SummaryData->get(Summary::MaxInternalBlockCount),
959 SummaryData->get(Summary::MaxFunctionCount),
960 SummaryData->get(Summary::TotalNumBlocks),
961 SummaryData->get(Summary::TotalNumFunctions));
962 return Cur + SummarySize;
970 Summary =
Builder.getSummary();
976 using namespace support;
978 const unsigned char *Start =
979 (
const unsigned char *)DataBuffer->getBufferStart();
980 const unsigned char *Cur = Start;
981 if ((
const unsigned char *)DataBuffer->getBufferEnd() - Cur < 24)
986 return HeaderOr.takeError();
989 Cur += Header->size();
993 if (Header->formatVersion() & VARIANT_MASK_CSIR_PROF)
999 endian::byte_swap<uint64_t, little>(Header->HashType));
1003 uint64_t HashOffset = endian::byte_swap<uint64_t, little>(Header->HashOffset);
1006 auto IndexPtr = std::make_unique<InstrProfReaderIndex<OnDiskHashTableImplV3>>(
1007 Start + HashOffset, Cur, Start, HashType, Header->formatVersion());
1011 if (GET_VERSION(Header->formatVersion()) >= 8 &&
1012 Header->formatVersion() & VARIANT_MASK_MEMPROF) {
1014 endian::byte_swap<uint64_t, little>(Header->MemProfOffset);
1016 const unsigned char *
Ptr = Start + MemProfOffset;
1019 support::endian::readNext<uint64_t, little, unaligned>(
Ptr);
1022 const uint64_t FramePayloadOffset =
1023 support::endian::readNext<uint64_t, little, unaligned>(
Ptr);
1026 support::endian::readNext<uint64_t, little, unaligned>(
Ptr);
1031 return SchemaOr.takeError();
1032 Schema = SchemaOr.get();
1036 Start + RecordTableOffset,
1042 Start + FrameTableOffset,
1043 Start + FramePayloadOffset,
1049 if (GET_VERSION(Header->formatVersion()) >= 9) {
1051 endian::byte_swap<uint64_t, little>(Header->BinaryIdOffset);
1052 const unsigned char *
Ptr = Start + BinaryIdOffset;
1054 BinaryIdsSize = support::endian::readNext<uint64_t, little, unaligned>(
Ptr);
1055 if (BinaryIdsSize %
sizeof(
uint64_t))
1058 BinaryIdsStart =
Ptr;
1059 if (BinaryIdsStart > (
const unsigned char *)DataBuffer->getBufferEnd())
1061 "corrupted binary ids");
1065 if (RemappingBuffer) {
1067 std::make_unique<InstrProfReaderItaniumRemapper<OnDiskHashTableImplV3>>(
1068 std::move(RemappingBuffer), *IndexPtr);
1069 if (
Error E = Remapper->populateRemappings())
1072 Remapper = std::make_unique<InstrProfReaderNullRemapper>(*IndexPtr);
1074 Index = std::move(IndexPtr);
1083 std::unique_ptr<InstrProfSymtab> NewSymtab = std::make_unique<InstrProfSymtab>();
1084 if (
Error E =
Index->populateSymtab(*NewSymtab)) {
1088 Symtab = std::move(NewSymtab);
1096 Error Err = Remapper->getRecords(FuncName,
Data);
1098 return std::move(Err);
1103 bool CSBitMatch =
false;
1104 auto getFuncSum = [](
const std::vector<uint64_t> &Counts) {
1106 for (
uint64_t CountValue : Counts) {
1110 if (std::numeric_limits<uint64_t>::max() - CountValue <= ValueSum)
1111 return std::numeric_limits<uint64_t>::max();
1112 ValueSum += CountValue;
1119 if (
I.Hash == FuncHash)
1120 return std::move(
I);
1124 if (MismatchedFuncSum ==
nullptr)
1126 FuncSum = std::max(FuncSum, getFuncSum(
I.Counts));
1130 if (MismatchedFuncSum !=
nullptr)
1131 *MismatchedFuncSum = FuncSum;
1140 if (MemProfRecordTable ==
nullptr)
1142 "no memprof data available in profile");
1143 auto Iter = MemProfRecordTable->find(FuncNameHash);
1144 if (Iter == MemProfRecordTable->end())
1145 return make_error<InstrProfError>(
1147 "memprof record not found for function hash " +
Twine(FuncNameHash));
1152 bool HasFrameMappingError =
false;
1154 auto FrIter = MemProfFrameTable->find(Id);
1155 if (FrIter == MemProfFrameTable->end()) {
1156 LastUnmappedFrameId = Id;
1157 HasFrameMappingError =
true;
1166 if (HasFrameMappingError) {
1168 "memprof frame not found for frame id " +
1169 Twine(LastUnmappedFrameId));
1176 std::vector<uint64_t> &Counts) {
1179 return error(std::move(
E));
1181 Counts =
Record.get().Counts;
1190 return error(std::move(
E));
1193 if (RecordIndex >=
Data.size()) {
1194 Index->advanceToNextKey();
1201 std::vector<llvm::object::BuildID> &BinaryIds) {
1213 for (
const auto &Func : *
this) {
1216 if (FuncIsCS != IsCS)
1219 Func.accumulateCounts(Sum);
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
Provides ErrorOr<T> smart pointer.
static Expected< std::unique_ptr< MemoryBuffer > > setupMemoryBuffer(const Twine &Filename, vfs::FileSystem &FS)
static Error printBinaryIdsInternal(raw_ostream &OS, const MemoryBuffer &DataBuffer, uint64_t BinaryIdsSize, const uint8_t *BinaryIdsStart, llvm::support::endianness Endian)
static Error initializeReader(InstrProfReader &Reader)
#define READ_NUM(Str, Dst)
#define CHECK_LINE_END(Line)
#define VP_READ_ADVANCE(Val)
static InstrProfKind getProfileKindFromVersion(uint64_t Version)
static Error readBinaryIdsInternal(const MemoryBuffer &DataBuffer, const uint64_t BinaryIdsSize, const uint8_t *BinaryIdsStart, std::vector< llvm::object::BuildID > &BinaryIds, const llvm::support::endianness Endian)
Read a list of binary ids from a profile that consist of a.
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Defines the virtual file system interface vfs::FileSystem.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
Reader for the indexed binary instrprof format.
Error readNextRecord(NamedInstrProfRecord &Record) override
Read a single record.
static Expected< std::unique_ptr< IndexedInstrProfReader > > create(const Twine &Path, vfs::FileSystem &FS, const Twine &RemappingPath="")
Factory method to create an indexed reader.
Expected< memprof::MemProfRecord > getMemProfRecord(uint64_t FuncNameHash)
Return the memprof record for the function identified by llvm::md5(Name).
Error readHeader() override
Read the file header.
Error printBinaryIds(raw_ostream &OS) override
Print binary ids.
Expected< InstrProfRecord > getInstrProfRecord(StringRef FuncName, uint64_t FuncHash, uint64_t *MismatchedFuncSum=nullptr)
Return the NamedInstrProfRecord associated with FuncName and FuncHash.
InstrProfSymtab & getSymtab() override
Return the PGO symtab.
static bool hasFormat(const MemoryBuffer &DataBuffer)
Return true if the given buffer is in an indexed instrprof format.
Error getFunctionCounts(StringRef FuncName, uint64_t FuncHash, std::vector< uint64_t > &Counts)
Fill Counts with the profile data for the given function name.
Error readBinaryIds(std::vector< llvm::object::BuildID > &BinaryIds) override
Read a list of binary ids.
InstrProfCorrelator - A base class used to create raw instrumentation data to their functions.
static instrprof_error take(Error E)
Consume an Error and return the raw enum value contained within it.
data_type ReadData(StringRef K, const unsigned char *D, offset_type N)
bool readValueProfilingData(const unsigned char *&D, const unsigned char *const End)
hash_value_type ComputeHash(StringRef K)
ArrayRef< NamedInstrProfRecord > data_type
InstrProfKind getProfileKind() const override
Error getRecords(ArrayRef< NamedInstrProfRecord > &Data) override
InstrProfReaderIndex(const unsigned char *Buckets, const unsigned char *const Payload, const unsigned char *const Base, IndexedInstrProf::HashT HashType, uint64_t Version)
A remapper that applies remappings based on a symbol remapping file.
static StringRef extractName(StringRef Name)
Extract the original function name from a PGO function name.
InstrProfReaderItaniumRemapper(std::unique_ptr< MemoryBuffer > RemapBuffer, InstrProfReaderIndex< HashTableImpl > &Underlying)
Error populateRemappings() override
static void reconstituteName(StringRef OrigName, StringRef ExtractedName, StringRef Replacement, SmallVectorImpl< char > &Out)
Given a mangled name extracted from a PGO function name, and a new form for that mangled name,...
Error getRecords(StringRef FuncName, ArrayRef< NamedInstrProfRecord > &Data) override
Name matcher supporting fuzzy matching of symbol names to names in profiles.
Base class and interface for reading profiling data of any known instrprof format.
static Expected< std::unique_ptr< InstrProfReader > > create(const Twine &Path, vfs::FileSystem &FS, const InstrProfCorrelator *Correlator=nullptr)
Factory method to create an appropriately typed reader for the given instrprof file.
std::unique_ptr< InstrProfSymtab > Symtab
Error success()
Clear the current error and return a successful one.
virtual bool isIRLevelProfile() const =0
virtual Error readHeader()=0
Read the header. Required before reading first record.
void accumulateCounts(CountSumOrPercent &Sum, bool IsCS)
Compute the sum of counts and return in Sum.
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
static bool isExternalSymbol(const StringRef &Symbol)
True if Symbol is the value used to represent external symbols.
void mapAddress(uint64_t Addr, uint64_t MD5Val)
Map a function address to its name's MD5 hash.
Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
size_t getBufferSize() const
const char * getBufferEnd() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
const char * getBufferStart() const
static OnDiskIterableChainedHashTable * Create(const unsigned char *Buckets, const unsigned char *const Payload, const unsigned char *const Base, const Info &InfoObj=Info())
Create the hash table.
static const ArrayRef< uint32_t > DefaultCutoffs
A vector of useful cutoff values for detailed summary.
Reader for the raw instrprof binary format from runtime.
Error readHeader() override
Read the header. Required before reading first record.
Error readNextRecord(NamedInstrProfRecord &Record) override
Read a single record.
Error printBinaryIds(raw_ostream &OS) override
Print binary ids.
static bool hasFormat(const MemoryBuffer &DataBuffer)
InstrProfKind getProfileKind() const override
Returns a BitsetEnum describing the attributes of the raw instr profile.
Error readBinaryIds(std::vector< llvm::object::BuildID > &BinaryIds) override
Read a list of binary ids.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
iterator insert(iterator I, T &&Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
bool startswith(StringRef Prefix) const
std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
Reader for symbol remapping files.
Key insert(StringRef FunctionName)
Construct a key for the given symbol, or return an existing one if an equivalent name has already bee...
Key lookup(StringRef FunctionName)
Map the given symbol name into the key for the corresponding equivalence class.
Error read(MemoryBuffer &B)
Read remappings from the given buffer, which must live as long as the remapper.
Reader for the simple text based instrprof format.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if the given buffer is in text instrprof format.
Error readNextRecord(NamedInstrProfRecord &Record) override
Read a single record.
Error readHeader() override
Read the header.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
LLVM Value Representation.
bool is_at_end() const
Return true if we're an "end" iterator or have reached EOF.
This class implements an extremely fast bulk output stream that can only output to a stream.
The virtual file system interface.
std::unique_ptr< Summary > allocSummary(uint32_t TotalSize)
uint64_t ComputeHash(StringRef K)
Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
unsigned char getSwappedBytes(unsigned char C)
This is an optimization pass for GlobalISel generic memory operations.
RawInstrProfReader< uint32_t > RawInstrProfReader32
uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align)
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
std::vector< ProfileSummaryEntry > SummaryEntryVector
@ missing_debug_info_for_correlation
@ unexpected_debug_info_for_correlation
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
RawInstrProfReader< uint64_t > RawInstrProfReader64
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
InstrProfKind
An enum describing the attributes of an instrumented profile.
@ FunctionEntryInstrumentation
@ FrontendInstrumentation
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
uint64_t Cutoff
The required percentile of total execution count.
uint64_t NumBlocks
Number of blocks >= the minumum execution count.
uint64_t MinBlockCount
The minimum execution count for this percentile.
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries)
uint64_t NumSummaryFields
uint64_t NumCutoffEntries
Profiling information for a single function.
static bool hasCSFlagInHash(uint64_t FuncHash)