209 #ifndef LLVM_PROFILEDATA_SAMPLEPROFREADER_H 210 #define LLVM_PROFILEDATA_SAMPLEPROFREADER_H 229 #include <system_error> 236 namespace sampleprof {
277 virtual std::error_code
read() = 0;
354 std::error_code
read()
override;
370 std::error_code
read()
override;
379 template <
typename T>
ErrorOr<T> readNumber();
402 const uint8_t *End =
nullptr;
405 std::error_code readSummaryEntry(std::vector<ProfileSummaryEntry> &Entries);
406 virtual std::error_code verifySPMagic(uint64_t
Magic) = 0;
409 std::error_code readSummary();
412 virtual std::error_code readNameTable() = 0;
421 std::vector<StringRef> NameTable;
422 virtual std::error_code verifySPMagic(uint64_t
Magic)
override;
423 virtual std::error_code readNameTable()
override;
438 std::vector<std::string> NameTable;
439 virtual std::error_code verifySPMagic(uint64_t
Magic)
override;
440 virtual std::error_code readNameTable()
override;
472 GcovBuffer(
Buffer.get()) {}
478 std::error_code
read()
override;
484 std::error_code readNameTable();
485 std::error_code readOneFunctionProfile(
const InlineCallStack &InlineStack,
487 std::error_code readFunctionProfiles();
488 std::error_code skipNextWord();
489 template <
typename T>
ErrorOr<T> readNumber();
502 static const uint32_t GCOVTagAFDOFileNames = 0xaa000000;
503 static const uint32_t GCOVTagAFDOFunction = 0xac000000;
510 #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.
Compute iterated dominance frontiers using a linear time algorithm.
static StringRef getRepInFormat(StringRef Name, SampleProfileFormat Format, std::string &GUIDBuf)
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)
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...
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)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
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.
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.