41 #include <system_error> 45 using namespace sampleprof;
53 OS <<
"Function: " << FName <<
": " <<
Profiles[FName];
70 uint64_t &NumSamples, uint64_t &NumHeadSamples) {
73 size_t n2 = Input.
rfind(
':');
74 size_t n1 = Input.
rfind(
':', n2 - 1);
75 FName = Input.
substr(0, n1);
98 uint64_t &NumSamples,
uint32_t &LineOffset,
101 for (Depth = 0; Input[
Depth] ==
' '; Depth++)
106 size_t n1 = Input.
find(
':');
108 size_t n2 = Loc.
find(
'.');
121 if (Rest[0] >=
'0' && Rest[0] <=
'9') {
123 size_t n3 = Rest.
find(
' ');
156 Target = Rest.
substr(0, n3);
172 TargetCountMap[Target] =
count;
173 if (n4 == Rest.
size())
181 CalleeName = Rest.
substr(0, n3);
201 if ((*LineIt)[(*LineIt).find_first_not_of(
' ')] ==
'#')
215 if ((*LineIt)[0] !=
' ') {
216 uint64_t NumSamples, NumHeadSamples;
218 if (!
ParseHead(*LineIt, FName, NumSamples, NumHeadSamples)) {
220 "Expected 'mangled_name:NUM:NUM', found " + *LineIt);
236 if (!
ParseLine(*LineIt, IsCallsite, Depth, NumSamples, LineOffset,
237 Discriminator, FName, TargetCountMap)) {
239 "Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found " +
257 for (
const auto &name_count : TargetCountMap) {
259 LineOffset, Discriminator, name_count.first,
279 if ((*LineIt)[0] !=
' ') {
280 uint64_t NumSamples, NumHeadSamples;
282 result =
ParseHead(*LineIt, FName, NumSamples, NumHeadSamples);
290 unsigned NumBytesRead = 0;
296 else if (
Data + NumBytesRead > End)
306 Data += NumBytesRead;
307 return static_cast<T>(Val);
323 template <
typename T>
327 if (
Data +
sizeof(
T) > End) {
333 using namespace support;
334 T Val = endian::readNext<T, little, unaligned>(
Data);
338 template <
typename T>
341 auto Idx = readNumber<uint32_t>();
342 if (std::error_code EC = Idx.getError())
344 if (*Idx >= Table.size())
350 auto Idx = readStringIndex(NameTable);
351 if (std::error_code EC = Idx.getError())
354 return NameTable[*Idx];
358 auto Idx = readStringIndex(NameTable);
359 if (std::error_code EC = Idx.getError())
367 auto NumSamples = readNumber<uint64_t>();
368 if (std::error_code EC = NumSamples.getError())
373 auto NumRecords = readNumber<uint32_t>();
374 if (std::error_code EC = NumRecords.getError())
378 auto LineOffset = readNumber<uint64_t>();
379 if (std::error_code EC = LineOffset.getError())
383 return std::error_code();
386 auto Discriminator = readNumber<uint64_t>();
387 if (std::error_code EC = Discriminator.getError())
390 auto NumSamples = readNumber<uint64_t>();
391 if (std::error_code EC = NumSamples.getError())
394 auto NumCalls = readNumber<uint32_t>();
395 if (std::error_code EC = NumCalls.getError())
398 for (
uint32_t J = 0; J < *NumCalls; ++J) {
399 auto CalledFunction(readStringFromTable());
400 if (std::error_code EC = CalledFunction.getError())
403 auto CalledFunctionSamples = readNumber<uint64_t>();
404 if (std::error_code EC = CalledFunctionSamples.getError())
408 *CalledFunction, *CalledFunctionSamples);
411 FProfile.
addBodySamples(*LineOffset, *Discriminator, *NumSamples);
415 auto NumCallsites = readNumber<uint32_t>();
416 if (std::error_code EC = NumCallsites.getError())
419 for (
uint32_t J = 0; J < *NumCallsites; ++J) {
420 auto LineOffset = readNumber<uint64_t>();
421 if (std::error_code EC = LineOffset.getError())
424 auto Discriminator = readNumber<uint64_t>();
425 if (std::error_code EC = Discriminator.getError())
428 auto FName(readStringFromTable());
429 if (std::error_code EC = FName.getError())
435 if (std::error_code EC = readProfile(CalleeProfile))
445 auto NumHeadSamples = readNumber<uint64_t>();
446 if (std::error_code EC = NumHeadSamples.getError())
449 auto FName(readStringFromTable());
450 if (std::error_code EC = FName.getError())
459 if (std::error_code EC = readProfile(FProfile))
466 if (std::error_code EC = readFuncProfile(
Data))
474 SampleProfileReaderExtBinary::readOneSection(
const uint8_t *Start,
480 if (std::error_code EC = readSummary())
484 if (std::error_code EC = readNameTable())
488 if (std::error_code EC = readFuncProfiles())
492 if (std::error_code EC = readProfileSymbolList())
496 if (std::error_code EC = readFuncOffsetTable())
512 std::error_code SampleProfileReaderExtBinary::readFuncOffsetTable() {
513 auto Size = readNumber<uint64_t>();
514 if (std::error_code EC =
Size.getError())
517 FuncOffsetTable.reserve(*
Size);
519 auto FName(readStringFromTable());
520 if (std::error_code EC = FName.getError())
523 auto Offset = readNumber<uint64_t>();
524 if (std::error_code EC =
Offset.getError())
527 FuncOffsetTable[*FName] = *
Offset;
532 std::error_code SampleProfileReaderExtBinary::readFuncProfiles() {
533 const uint8_t *Start =
Data;
536 if (std::error_code EC = readFuncProfile(
Data))
539 assert(
Data == End &&
"More data is read than expected");
544 for (
auto Name : FuncsToUse) {
549 for (
auto NameOffset : FuncOffsetTable) {
550 auto FuncName = NameOffset.first;
551 if (!FuncsToUse.count(FuncName) &&
554 const uint8_t *FuncProfileAddr = Start + NameOffset.second;
555 assert(FuncProfileAddr < End &&
"out of LBRProfile section");
556 if (std::error_code EC = readFuncProfile(FuncProfileAddr))
564 std::error_code SampleProfileReaderExtBinary::readProfileSymbolList() {
566 ProfSymList = std::make_unique<ProfileSymbolList>();
568 if (std::error_code EC = ProfSymList->read(
Data, End -
Data))
575 std::error_code SampleProfileReaderExtBinaryBase::decompressSection(
576 const uint8_t *SecStart,
const uint64_t SecSize,
577 const uint8_t *&DecompressBuf, uint64_t &DecompressBufSize) {
579 End = SecStart + SecSize;
580 auto DecompressSize = readNumber<uint64_t>();
581 if (std::error_code EC = DecompressSize.getError())
583 DecompressBufSize = *DecompressSize;
585 auto CompressSize = readNumber<uint64_t>();
586 if (std::error_code EC = CompressSize.getError())
592 StringRef CompressedStrings(reinterpret_cast<const char *>(
Data),
595 size_t UCSize = DecompressBufSize;
600 DecompressBuf =
reinterpret_cast<const uint8_t *
>(
Buffer);
605 const uint8_t *BufStart =
606 reinterpret_cast<const uint8_t *
>(
Buffer->getBufferStart());
608 for (
auto &
Entry : SecHdrTable) {
613 const uint8_t *SecStart = BufStart +
Entry.Offset;
614 uint64_t SecSize =
Entry.Size;
622 const uint8_t *DecompressBuf;
623 uint64_t DecompressBufSize;
624 if (std::error_code EC = decompressSection(
625 SecStart, SecSize, DecompressBuf, DecompressBufSize))
627 SecStart = DecompressBuf;
628 SecSize = DecompressBufSize;
631 if (std::error_code EC = readOneSection(SecStart, SecSize,
Entry.Type))
633 if (
Data != SecStart + SecSize)
639 End = BufStart +
Buffer->getBufferSize();
647 std::vector<uint64_t> OffsetsToUse;
649 for (
auto FuncEntry : FuncOffsetTable) {
650 OffsetsToUse.push_back(FuncEntry.second);
654 for (
auto Name : FuncsToUse) {
656 auto iter = FuncOffsetTable.find(
StringRef(GUID));
657 if (iter == FuncOffsetTable.end())
659 OffsetsToUse.push_back(iter->second);
663 for (
auto Offset : OffsetsToUse) {
664 const uint8_t *SavedData =
Data;
665 if (std::error_code EC = readFuncProfile(
666 reinterpret_cast<const uint8_t *>(
Buffer->getBufferStart()) +
674 std::error_code SampleProfileReaderRawBinary::verifySPMagic(uint64_t
Magic) {
680 std::error_code SampleProfileReaderExtBinary::verifySPMagic(uint64_t
Magic) {
687 SampleProfileReaderCompactBinary::verifySPMagic(uint64_t
Magic) {
694 auto Size = readNumber<uint32_t>();
695 if (std::error_code EC =
Size.getError())
697 NameTable.reserve(*
Size);
700 if (std::error_code EC =
Name.getError())
702 NameTable.push_back(*
Name);
708 std::error_code SampleProfileReaderCompactBinary::readNameTable() {
709 auto Size = readNumber<uint64_t>();
710 if (std::error_code EC =
Size.getError())
712 NameTable.reserve(*
Size);
714 auto FID = readNumber<uint64_t>();
715 if (std::error_code EC = FID.getError())
724 auto Type = readUnencodedNumber<uint64_t>();
725 if (std::error_code EC =
Type.getError())
729 auto Flags = readUnencodedNumber<uint64_t>();
730 if (std::error_code EC = Flags.getError())
732 Entry.
Flags = *Flags;
734 auto Offset = readUnencodedNumber<uint64_t>();
735 if (std::error_code EC =
Offset.getError())
739 auto Size = readUnencodedNumber<uint64_t>();
740 if (std::error_code EC =
Size.getError())
744 SecHdrTable.push_back(std::move(Entry));
749 auto EntryNum = readUnencodedNumber<uint64_t>();
750 if (std::error_code EC = EntryNum.getError())
753 for (
uint32_t i = 0; i < (*EntryNum); i++)
754 if (std::error_code EC = readSecHdrTableEntry())
761 const uint8_t *BufStart =
762 reinterpret_cast<const uint8_t *
>(
Buffer->getBufferStart());
764 End = BufStart +
Buffer->getBufferSize();
766 if (std::error_code EC = readMagicIdent())
769 if (std::error_code EC = readSecHdrTable())
776 for (
auto &
Entry : SecHdrTable) {
777 if (
Entry.Type == Type)
789 uint64_t FileSize = 0;
790 for (
auto &
Entry : SecHdrTable) {
797 uint64_t TotalSecsSize = 0;
798 for (
auto &
Entry : SecHdrTable) {
800 <<
", Size: " <<
Entry.Size <<
"\n";
801 TotalSecsSize += getSectionSize(
Entry.Type);
803 uint64_t
HeaderSize = SecHdrTable.front().Offset;
804 assert(HeaderSize + TotalSecsSize == getFileSize() &&
805 "Size of 'header + sections' doesn't match the total size of profile");
807 OS <<
"Header Size: " << HeaderSize <<
"\n";
808 OS <<
"Total Sections Size: " << TotalSecsSize <<
"\n";
809 OS <<
"File Size: " << getFileSize() <<
"\n";
815 auto Magic = readNumber<uint64_t>();
816 if (std::error_code EC =
Magic.getError())
818 else if (std::error_code EC = verifySPMagic(*
Magic))
822 auto Version = readNumber<uint64_t>();
823 if (std::error_code EC =
Version.getError())
832 Data =
reinterpret_cast<const uint8_t *
>(
Buffer->getBufferStart());
835 if (std::error_code EC = readMagicIdent())
838 if (std::error_code EC = readSummary())
841 if (std::error_code EC = readNameTable())
846 std::error_code SampleProfileReaderCompactBinary::readHeader() {
848 if (std::error_code EC = readFuncOffsetTable())
853 std::error_code SampleProfileReaderCompactBinary::readFuncOffsetTable() {
854 auto TableOffset = readUnencodedNumber<uint64_t>();
855 if (std::error_code EC = TableOffset.getError())
858 const uint8_t *SavedData =
Data;
859 const uint8_t *TableStart =
860 reinterpret_cast<const uint8_t *
>(
Buffer->getBufferStart()) +
864 auto Size = readNumber<uint64_t>();
865 if (std::error_code EC =
Size.getError())
868 FuncOffsetTable.reserve(*
Size);
870 auto FName(readStringFromTable());
871 if (std::error_code EC = FName.getError())
874 auto Offset = readNumber<uint64_t>();
875 if (std::error_code EC =
Offset.getError())
878 FuncOffsetTable[*FName] = *
Offset;
892 std::error_code SampleProfileReaderBinary::readSummaryEntry(
893 std::vector<ProfileSummaryEntry> &Entries) {
894 auto Cutoff = readNumber<uint64_t>();
895 if (std::error_code EC = Cutoff.getError())
898 auto MinBlockCount = readNumber<uint64_t>();
899 if (std::error_code EC = MinBlockCount.getError())
902 auto NumBlocks = readNumber<uint64_t>();
903 if (std::error_code EC = NumBlocks.getError())
906 Entries.emplace_back(*Cutoff, *MinBlockCount, *NumBlocks);
911 auto TotalCount = readNumber<uint64_t>();
912 if (std::error_code EC = TotalCount.getError())
915 auto MaxBlockCount = readNumber<uint64_t>();
916 if (std::error_code EC = MaxBlockCount.getError())
919 auto MaxFunctionCount = readNumber<uint64_t>();
920 if (std::error_code EC = MaxFunctionCount.getError())
923 auto NumBlocks = readNumber<uint64_t>();
924 if (std::error_code EC = NumBlocks.getError())
927 auto NumFunctions = readNumber<uint64_t>();
928 if (std::error_code EC = NumFunctions.getError())
931 auto NumSummaryEntries = readNumber<uint64_t>();
932 if (std::error_code EC = NumSummaryEntries.getError())
935 std::vector<ProfileSummaryEntry> Entries;
936 for (
unsigned i = 0; i < *NumSummaryEntries; i++) {
937 std::error_code EC = readSummaryEntry(Entries);
941 Summary = std::make_unique<ProfileSummary>(
943 *MaxFunctionCount, *NumBlocks, *NumFunctions);
949 const uint8_t *
Data =
956 const uint8_t *
Data =
963 const uint8_t *
Data =
971 if (!GcovBuffer.readInt(dummy))
980 return static_cast<T>(Val);
981 }
else if (
sizeof(
T) <=
sizeof(uint64_t)) {
984 return static_cast<T>(Val);
994 if (!GcovBuffer.readString(Str))
1001 if (!GcovBuffer.readGCDAFormat())
1007 if (!GcovBuffer.readGCOVVersion(version))
1014 if (std::error_code EC = skipNextWord())
1022 if (!GcovBuffer.readInt(Tag))
1025 if (Tag != Expected)
1028 if (std::error_code EC = skipNextWord())
1035 if (std::error_code EC = readSectionTag(GCOVTagAFDOFileNames))
1039 if (!GcovBuffer.readInt(Size))
1044 if (!GcovBuffer.readString(Str))
1046 Names.push_back(Str);
1053 if (std::error_code EC = readSectionTag(GCOVTagAFDOFunction))
1057 if (!GcovBuffer.readInt(NumFunctions))
1062 if (std::error_code EC = readOneFunctionProfile(Stack,
true, 0))
1071 uint64_t HeadCount = 0;
1072 if (InlineStack.
size() == 0)
1073 if (!GcovBuffer.readInt64(HeadCount))
1077 if (!GcovBuffer.readInt(NameIdx))
1083 if (!GcovBuffer.readInt(NumPosCounts))
1087 if (!GcovBuffer.readInt(NumCallsites))
1091 if (InlineStack.
size() == 0) {
1107 uint32_t LineOffset = Offset >> 16;
1108 uint32_t Discriminator = Offset & 0xffff;
1116 if (!GcovBuffer.readInt(Offset))
1120 if (!GcovBuffer.readInt(NumTargets))
1124 if (!GcovBuffer.readInt64(Count))
1130 uint32_t LineOffset = Offset >> 16;
1131 uint32_t Discriminator = Offset & 0xffff;
1139 for (
auto CallerProfile : NewStack)
1140 CallerProfile->addTotalSamples(Count);
1149 for (
uint32_t J = 0; J < NumTargets; J++) {
1151 if (!GcovBuffer.readInt(HistVal))
1158 if (!GcovBuffer.readInt64(TargetIdx))
1162 uint64_t TargetCount;
1163 if (!GcovBuffer.readInt64(TargetCount))
1168 TargetName, TargetCount);
1179 if (!GcovBuffer.readInt(Offset))
1184 if (std::error_code EC = readOneFunctionProfile(NewStack, Update, Offset))
1197 if (std::error_code EC = readNameTable())
1201 if (std::error_code EC = readFunctionProfiles())
1209 return Magic ==
"adcg*704";
1217 Reader.getBuffer()->getBufferIdentifier(),
1218 "Profile data remapping cannot be applied to profile data " 1219 "in compact format (original mangled names are not available).",
1224 assert(Remappings &&
"should be initialized while creating remapper");
1225 for (
auto &Sample : Reader.getProfiles())
1226 if (
auto Key = Remappings->insert(Sample.first()))
1227 SampleMap.insert({
Key, &Sample.second});
1229 RemappingApplied =
true;
1234 if (
auto Key = Remappings->lookup(Fname))
1235 return SampleMap.lookup(
Key);
1245 if (std::error_code EC = BufferOrErr.getError())
1247 auto Buffer = std::move(BufferOrErr.get());
1253 return std::move(
Buffer);
1267 const std::string RemapFilename) {
1269 if (std::error_code EC = BufferOrError.getError())
1271 return create(BufferOrError.get(),
C, RemapFilename);
1289 if (std::error_code EC = BufferOrError.getError())
1291 return create(BufferOrError.get(), Reader,
C);
1308 auto Remappings = std::make_unique<SymbolRemappingReader>();
1309 if (
Error E = Remappings->read(*B.get())) {
1319 return std::make_unique<SampleProfileReaderItaniumRemapper>(
1320 std::move(B), std::move(Remappings), Reader);
1334 const std::string RemapFilename) {
1335 std::unique_ptr<SampleProfileReader> Reader;
1349 if (!RemapFilename.empty()) {
1352 if (std::error_code EC = ReaderOrErr.getError()) {
1353 std::string Msg =
"Could not create remapper: " + EC.message();
1357 Reader->Remapper = std::move(ReaderOrErr.get());
1361 if (std::error_code EC = Reader->readHeader()) {
1365 return std::move(Reader);
std::unique_ptr< MemoryBuffer > Buffer
Memory buffer holding the profile file.
Represents either an error or a value T.
std::error_code readImpl() override
Read sample profiles from the associated file.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
static ErrorOr< std::unique_ptr< SampleProfileReader > > create(const std::string Filename, LLVMContext &C, const std::string RemapFilename="")
Create a sample profile reader appropriate to the file format.
FunctionSamples * getSamplesFor(StringRef FunctionName)
Return the samples collected for function F if remapper knows it is present in SampleMap.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
void push_back(const T &Elt)
void addRecord(const sampleprof::FunctionSamples &FS, bool isCallsiteSample=false)
std::error_code readSummary()
Read profile summary.
virtual std::error_code readHeader() override
Read and validate the file header.
uint64_t MD5Hash(StringRef Str)
Helper to compute and return lower 64 bits of the given string's MD5 hash.
void applyRemapping(LLVMContext &Ctx)
Apply remappings to the profile read by Reader.
std::error_code readImpl() override
Read sample profiles in extensible format from the associated file.
LLVM_NODISCARD size_t find_last_of(char C, size_t From=npos) const
Find the last character in the string that is C, or npos if not found.
A forward iterator which reads text lines from a buffer.
static const ArrayRef< uint32_t > DefaultCutoffs
A vector of useful cutoff values for detailed summary.
std::error_code readProfile(FunctionSamples &FProfile)
Read the contents of the given profile instance.
static SampleProfileFormat Format
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if Buffer is in the format supported by this class.
Representation of the samples collected for a function.
static std::string getSecName(SecType Type)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static bool hasSecFlag(SecHdrTableEntry &Entry, SecFlags Flag)
StringRef getMessage() const
virtual std::error_code readNameTable()
Read the whole name table.
StringMap< FunctionSamples > Profiles
Map every function to its associated profile.
Tagged union holding either a T or a Error.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
void collectFuncsFrom(const Module &M) override
Collect functions with definitions in Module M.
bool is_at_eof() const
Return true if we've reached EOF or are an "end" iterator.
std::error_code readImpl() override
Read sample profiles from the associated file.
ErrorOr< T > readNumber()
std::error_code readNameTable()
static bool ParseHead(const StringRef &Input, StringRef &FName, uint64_t &NumSamples, uint64_t &NumHeadSamples)
Parse Input as function head.
LLVM_NODISCARD size_t size() const
size - Get the string size.
void setName(StringRef FunctionName)
Set the name of the function.
std::error_code readImpl() override
Read samples only for functions to use.
std::error_code readFunctionProfiles()
static uint64_t SPVersion()
std::error_code readFuncProfile(const uint8_t *Start)
Read the next function profile instance.
std::error_code readSecHdrTableEntry()
static bool ParseLine(const StringRef &Input, bool &IsCallsite, uint32_t &Depth, uint64_t &NumSamples, uint32_t &LineOffset, uint32_t &Discriminator, StringRef &CalleeName, DenseMap< StringRef, uint64_t > &TargetCountMap)
Parse Input as line sample.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
int64_t line_number() const
Return the current line number. May return any number at EOF.
std::error_code readOneFunctionProfile(const InlineCallStack &InlineStack, bool Update, uint32_t Offset)
int64_t getLineNum() const
uint64_t getFileSize()
Get the total size of header and all sections.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static ErrorOr< std::unique_ptr< SampleProfileReaderItaniumRemapper > > create(const std::string Filename, SampleProfileReader &Reader, LLVMContext &C)
Create a remapper from the given remapping file.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if Buffer is in the format supported by this class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::error_code readSecHdrTable()
sampleprof_error addBodySamples(uint32_t LineOffset, uint32_t Discriminator, uint64_t Num, uint64_t Weight=1)
ErrorOr< T > readNumber()
Read a numeric value of type T from the profile.
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
LLVMContext & Ctx
LLVM context used to emit diagnostics.
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes...
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
ErrorOr< StringRef > readString()
Read a string from the profile.
virtual std::error_code readHeader() override
Read and validate the file header.
std::error_code readMagicIdent()
Read the contents of Magic number and Version number.
std::error_code readImpl() override
Read sample profiles from the associated file.
void dumpFunctionProfile(StringRef FName, raw_ostream &OS=dbgs())
Print the profile for FName on stream OS.
static const char *const Magic
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
virtual bool dumpSectionInfo(raw_ostream &OS=dbgs()) override
Align max(MaybeAlign Lhs, Align Rhs)
sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight=1)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
uint64_t getSectionSize(SecType Type)
Get the total size of all Type sections.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if Buffer is in the format supported by this class.
FunctionSamplesMap & functionSamplesAt(const LineLocation &Loc)
Return the function samples at the given callsite location.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
static StringRef readString(WasmObjectFile::ReadContext &Ctx)
Target - Wrapper for Target specific information.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if Buffer is in the format supported by this class.
static bool hasFormat(const MemoryBuffer &Buffer)
Return true if Buffer is in the format supported by this class.
iterator insert(iterator I, T &&Elt)
std::unique_ptr< ProfileSummary > getSummary()
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
ErrorOr< T > readUnencodedNumber()
Read a numeric value of type T from the profile.
ErrorOr< StringRef > readString()
Represents the relative location of an instruction.
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const char * getBufferStart() const
void collectFuncsFrom(const Module &M) override
Collect functions to be used when compiling Module M.
static uint64_t SPMagic(SampleProfileFormat Format=SPF_Binary)
sampleprof_error addHeadSamples(uint64_t Num, uint64_t Weight=1)
const std::string to_string(const T &Value)
Provides ErrorOr<T> smart pointer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::error_code readSectionTag(uint32_t Expected)
Read the section tag and check that it's the same as Expected.
static ErrorOr< std::unique_ptr< MemoryBuffer > > setupMemoryBuffer(const Twine &Filename)
Prepare a memory buffer for the contents of Filename.
uint64_t getTotalSamples() const
Return the total number of samples collected inside the function.
Lightweight error class with error context and mandatory checking.
ErrorOr< uint32_t > readStringIndex(T &Table)
Read the string index and check whether it overflows the table.
void reportError(int64_t LineNumber, Twine Msg) const
Report a parse error message.
Sample-based profile reader.
This class implements an extremely fast bulk output stream that can only output to a stream...
virtual ErrorOr< StringRef > readStringFromTable()
Read a string indirectly via the name table.
StringRef - Represent a constant reference to a string, i.e.
Diagnostic information for the sample profiler.
std::error_code readHeader() override
Read and validate the file header.
void computeSummary()
Compute summary for this profile.
void dump(raw_ostream &OS=dbgs())
Print all the profiles on stream OS.
Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize)
static bool isOffsetLegal(unsigned L)
Returns true if line offset L is legal (only has 16 bits).
sampleprof_error addCalledTargetSamples(uint32_t LineOffset, uint32_t Discriminator, StringRef FName, uint64_t Num, uint64_t Weight=1)
std::error_code skipNextWord()
sampleprof_error MergeResult(sampleprof_error &Accumulator, sampleprof_error Result)
std::unique_ptr< ProfileSummary > Summary
Profile summary information.
std::unique_ptr< SampleProfileReaderItaniumRemapper > Remapper