209 #ifndef LLVM_PROFILEDATA_SAMPLEPROFREADER_H 210 #define LLVM_PROFILEDATA_SAMPLEPROFREADER_H 230 #include <system_error> 237 namespace sampleprof {
278 virtual std::error_code
read() = 0;
347 static std::unique_ptr<ProfileSummary>
349 return std::move(Reader.
Summary);
368 std::error_code
read()
override;
381 virtual std::error_code
readHeader()
override;
384 std::error_code
read()
override;
393 template <
typename T>
ErrorOr<T> readNumber();
397 template <
typename T>
ErrorOr<T> readUnencodedNumber();
414 std::error_code readFuncProfile();
423 const uint8_t *End =
nullptr;
426 std::error_code readSummaryEntry(std::vector<ProfileSummaryEntry> &Entries);
427 virtual std::error_code verifySPMagic(uint64_t
Magic) = 0;
430 std::error_code readSummary();
433 virtual std::error_code readNameTable() = 0;
442 std::vector<StringRef> NameTable;
443 virtual std::error_code verifySPMagic(uint64_t
Magic)
override;
444 virtual std::error_code readNameTable()
override;
459 std::vector<std::string> NameTable;
465 virtual std::error_code verifySPMagic(uint64_t
Magic)
override;
466 virtual std::error_code readNameTable()
override;
469 virtual std::error_code
readHeader()
override;
470 std::error_code readFuncOffsetTable();
481 std::error_code
read()
override;
506 GcovBuffer(
Buffer.get()) {}
512 std::error_code
read()
override;
518 std::error_code readNameTable();
519 std::error_code readOneFunctionProfile(
const InlineCallStack &InlineStack,
521 std::error_code readFunctionProfiles();
522 std::error_code skipNextWord();
523 template <
typename T>
ErrorOr<T> readNumber();
536 static const uint32_t GCOVTagAFDOFileNames = 0xaa000000;
537 static const uint32_t GCOVTagAFDOFunction = 0xac000000;
547 std::unique_ptr<SampleProfileReader>
Underlying)
549 Profiles = std::move(Underlying->getProfiles());
553 UnderlyingReader = std::move(Underlying);
560 std::unique_ptr<SampleProfileReader>
Underlying);
566 std::error_code
read()
override;
575 std::unique_ptr<SampleProfileReader> UnderlyingReader;
582 #endif // LLVM_PROFILEDATA_SAMPLEPROFREADER_H std::vector< std::string > Names
Function names in this profile.
std::unique_ptr< MemoryBuffer > Buffer
Memory buffer holding the profile file.
Represents either an error or a value T.
This class represents lattice values for constants.
static StringRef getRepInFormat(StringRef Name, SampleProfileFormat Format, std::string &GUIDBuf)
A Module instance is used to store all the information related to an LLVM module. ...
Implements a dense probed hash-table based set.
static ErrorOr< std::unique_ptr< SampleProfileReader > > create(const Twine &Filename, LLVMContext &C)
Create a sample profile reader appropriate to the file format.
GCOVBuffer - A wrapper around MemoryBuffer to provide GCOV specific read operations.
SampleProfileReaderRawBinary(std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
virtual void collectFuncsToUse(const Module &M)
Representation of the samples collected for a function.
virtual std::error_code read()=0
Read sample profiles from the associated file.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static std::unique_ptr< ProfileSummary > takeSummary(SampleProfileReader &Reader)
Take ownership of the summary of this reader.
StringMap< FunctionSamples > Profiles
Map every function to its associated profile.
SampleProfileReader(std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
Tagged union holding either a T or a Error.
SampleProfileFormat getFormat()
Return the profile format.
SampleProfileReaderGCC(std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
virtual FunctionSamples * getSamplesFor(StringRef Fname)
Return the samples collected for function F.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
std::error_code readHeader() override
Read and validate the file header.
This is an important class for using LLVM in a threaded context.
FunctionSamples * getSamplesFor(const Function &F)
Return the samples collected for function F.
LLVMContext & Ctx
LLVM context used to emit diagnostics.
SampleProfileFormat Format
The format of sample.
std::underlying_type< E >::type Underlying(E Val)
Check that Val is in range for E, and return Val cast to E's underlying type.
A profile data reader proxy that remaps the profile data from another sample profile data reader...
void dumpFunctionProfile(StringRef FName, raw_ostream &OS=dbgs())
Print the profile for FName on stream OS.
static const char *const Magic
virtual ~SampleProfileReader()=default
bool at_eof() const
Return true if we've reached the end of file.
virtual std::error_code readHeader()=0
Read and validate the file header.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
static StringRef readString(WasmObjectFile::ReadContext &Ctx)
StringMap< FunctionSamples > & getProfiles()
Return all the profiles.
SampleProfileReaderItaniumRemapper(std::unique_ptr< MemoryBuffer > B, LLVMContext &C, std::unique_ptr< SampleProfileReader > Underlying)
Reader for symbol remapping files.
StringRef getName() const
Return a constant reference to the value's name.
std::error_code readHeader() override
Read and validate the file header.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Provides ErrorOr<T> smart pointer.
SampleProfileReaderText(std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
SampleProfileReaderBinary(std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
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...
StringRef - Represent a constant reference to a string, i.e.
GCOVBuffer GcovBuffer
GCOV buffer containing the profile.
Diagnostic information for the sample profiler.
void computeSummary()
Compute summary for this profile.
void dump(raw_ostream &OS=dbgs())
Print all the profiles on stream OS.
ProfileSummary & getSummary()
Return the profile summary.
SampleProfileReaderCompactBinary(std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
std::unique_ptr< ProfileSummary > Summary
Profile summary information.