16 #include "llvm/Config/llvm-config.h" 24 #include <system_error> 27 using namespace sampleprof;
30 namespace sampleprof {
43 const char *
name()
const noexcept
override {
return "llvm.sampleprof"; }
45 std::string message(
int IE)
const override {
51 return "Invalid sample profile data (bad magic)";
53 return "Unsupported sample profile format version";
55 return "Too much profile data";
57 return "Truncated profile data";
59 return "Malformed sample profile data";
61 return "Unrecognized sample profile encoding format";
63 return "Profile encoding format unsupported for writing operations";
65 return "Truncated function name table";
67 return "Unimplemented feature";
69 return "Counter overflow";
71 return "Ostream does not support seek";
87 if (Discriminator > 0)
88 OS <<
"." << Discriminator;
97 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 106 for (
const auto &
I : getCallTargets())
107 OS <<
" " <<
I.first() <<
":" <<
I.second;
112 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 124 OS << TotalSamples <<
", " << TotalHeadSamples <<
", " << BodySamples.size()
125 <<
" sampled lines\n";
128 if (!BodySamples.empty()) {
129 OS <<
"Samples collected in the function's body {\n";
131 for (
const auto &
SI : SortedBodySamples.
get()) {
133 OS <<
SI->first <<
": " <<
SI->second;
138 OS <<
"No samples collected in the function's body\n";
142 if (!CallsiteSamples.empty()) {
143 OS <<
"Samples collected in inlined callsites {\n";
146 for (
const auto &CS : SortedCallsiteSamples.
get()) {
147 for (
const auto &FS : CS->second) {
149 OS << CS->first <<
": inlined callee: " << FS.second.getName() <<
": ";
150 FS.second.print(OS, Indent + 4);
155 OS <<
"No inlined callsites in this function\n";
166 return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
176 for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
179 PrevDIL->getScope()->getSubprogram()->getLinkageName()));
185 for (
int i = S.
size() - 1; i >= 0 && FS !=
nullptr; i--) {
191 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) raw_ostream & operator<<(raw_ostream &OS, const LineLocation &Loc)
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void push_back(const T &Elt)
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
static SampleProfileFormat Format
Representation of the samples collected for a function.
void print(raw_ostream &OS=dbgs(), unsigned Indent=0) const
Print the samples collected for a function on stream OS.
static DenseMap< uint64_t, StringRef > GUIDToFuncNameMap
GUIDToFuncNameMap saves the mapping from GUID to the symbol name, for all the function symbols define...
void print(raw_ostream &OS, unsigned Indent) const
Print the sample record to the stream OS indented by Indent.
Representation of a single sample record.
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
const SamplesWithLocList & get() const
Sort a LocationT->SampleT map by LocationT.
const FunctionSamples * findFunctionSamples(const DILocation *DIL) const
Get the FunctionSamples of the inline instance where DIL originates from.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static ManagedStatic< _object_error_category > error_category
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const FunctionSamples * findFunctionSamplesAt(const LineLocation &Loc, StringRef CalleeName) const
Returns a pointer to FunctionSamples at the given callsite location Loc with callee CalleeName...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static Module * CurrentModule
static unsigned getOffset(const DILocation *DIL)
Returns the line offset to the start line of the subprogram.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const std::error_category & sampleprof_category()
void print(raw_ostream &OS) const
static ManagedStatic< SampleProfErrorCategoryType > ErrorCategory
unsigned getBaseDiscriminator() const
Returns the base discriminator stored in the discriminator.
Represents the relative location of an instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...