16 #include "llvm/Config/llvm-config.h" 24 #include <system_error> 27 using namespace sampleprof;
35 const char *
name()
const noexcept
override {
return "llvm.sampleprof"; }
37 std::string message(
int IE)
const override {
43 return "Invalid sample profile data (bad magic)";
45 return "Unsupported sample profile format version";
47 return "Too much profile data";
49 return "Truncated profile data";
51 return "Malformed sample profile data";
53 return "Unrecognized sample profile encoding format";
55 return "Profile encoding format unsupported for writing operations";
57 return "Truncated function name table";
59 return "Unimplemented feature";
61 return "Counter overflow";
77 if (Discriminator > 0)
78 OS <<
"." << Discriminator;
87 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 96 for (
const auto &
I : getCallTargets())
97 OS <<
" " <<
I.first() <<
":" <<
I.second;
102 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 114 OS << TotalSamples <<
", " << TotalHeadSamples <<
", " << BodySamples.size()
115 <<
" sampled lines\n";
118 if (!BodySamples.empty()) {
119 OS <<
"Samples collected in the function's body {\n";
121 for (
const auto &
SI : SortedBodySamples.
get()) {
123 OS <<
SI->first <<
": " <<
SI->second;
128 OS <<
"No samples collected in the function's body\n";
132 if (!CallsiteSamples.empty()) {
133 OS <<
"Samples collected in inlined callsites {\n";
136 for (
const auto &CS : SortedCallsiteSamples.
get()) {
137 for (
const auto &FS : CS->second) {
139 OS << CS->first <<
": inlined callee: " << FS.second.getName() <<
": ";
140 FS.second.print(OS, Indent + 4);
145 OS <<
"No inlined callsites in this function\n";
156 return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
166 for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
169 PrevDIL->getScope()->getSubprogram()->getLinkageName()));
175 for (
int i = S.
size() - 1; i >= 0 && FS !=
nullptr; i--) {
181 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) void push_back(const T &Elt)
raw_ostream & operator<<(raw_ostream &OS, const LineLocation &Loc)
Compute iterated dominance frontiers using a linear time algorithm.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
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.
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 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...