LLVM  14.0.0git
SampleProf.cpp
Go to the documentation of this file.
1 //=-- SampleProf.cpp - Sample profiling format support --------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains common definitions used in the reading and writing of
10 // sample profile data.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/Config/llvm-config.h"
17 #include "llvm/IR/PseudoProbe.h"
20 #include "llvm/Support/Compiler.h"
21 #include "llvm/Support/Debug.h"
22 #include "llvm/Support/Error.h"
24 #include "llvm/Support/LEB128.h"
27 #include <string>
28 #include <system_error>
29 
30 using namespace llvm;
31 using namespace sampleprof;
32 
34  "profile-symbol-list-cutoff", cl::Hidden, cl::init(-1), cl::ZeroOrMore,
35  cl::desc("Cutoff value about how many symbols in profile symbol list "
36  "will be used. This is very useful for performance debugging"));
37 
38 namespace llvm {
39 namespace sampleprof {
42 bool FunctionSamples::ProfileIsCS = false;
43 bool FunctionSamples::UseMD5 = false;
45 bool FunctionSamples::ProfileIsFS = false;
46 } // namespace sampleprof
47 } // namespace llvm
48 
49 namespace {
50 
51 // FIXME: This class is only here to support the transition to llvm::Error. It
52 // will be removed once this transition is complete. Clients should prefer to
53 // deal with the Error value directly, rather than converting to error_code.
54 class SampleProfErrorCategoryType : public std::error_category {
55  const char *name() const noexcept override { return "llvm.sampleprof"; }
56 
57  std::string message(int IE) const override {
58  sampleprof_error E = static_cast<sampleprof_error>(IE);
59  switch (E) {
61  return "Success";
63  return "Invalid sample profile data (bad magic)";
65  return "Unsupported sample profile format version";
67  return "Too much profile data";
69  return "Truncated profile data";
71  return "Malformed sample profile data";
73  return "Unrecognized sample profile encoding format";
75  return "Profile encoding format unsupported for writing operations";
77  return "Truncated function name table";
79  return "Unimplemented feature";
81  return "Counter overflow";
83  return "Ostream does not support seek";
85  return "Compress failure";
87  return "Uncompress failure";
89  return "Zlib is unavailable";
91  return "Function hash mismatch";
92  }
93  llvm_unreachable("A value of sampleprof_error has no message.");
94  }
95 };
96 
97 } // end anonymous namespace
98 
100 
102  return *ErrorCategory;
103 }
104 
106  OS << LineOffset;
107  if (Discriminator > 0)
108  OS << "." << Discriminator;
109 }
110 
112  const LineLocation &Loc) {
113  Loc.print(OS);
114  return OS;
115 }
116 
117 /// Merge the samples in \p Other into this record.
118 /// Optionally scale sample counts by \p Weight.
120  uint64_t Weight) {
121  sampleprof_error Result;
122  Result = addSamples(Other.getSamples(), Weight);
123  for (const auto &I : Other.getCallTargets()) {
124  MergeResult(Result, addCalledTarget(I.first(), I.second, Weight));
125  }
126  return Result;
127 }
128 
129 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
131 #endif
132 
133 /// Print the sample record to the stream \p OS indented by \p Indent.
134 void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
135  OS << NumSamples;
136  if (hasCalls()) {
137  OS << ", calls:";
138  for (const auto &I : getSortedCallTargets())
139  OS << " " << I.first << ":" << I.second;
140  }
141  OS << "\n";
142 }
143 
144 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
146 #endif
147 
149  const SampleRecord &Sample) {
150  Sample.print(OS, 0);
151  return OS;
152 }
153 
154 /// Print the samples collected for a function on stream \p OS.
155 void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
156  if (getFunctionHash())
157  OS << "CFG checksum " << getFunctionHash() << "\n";
158 
159  OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
160  << " sampled lines\n";
161 
162  OS.indent(Indent);
163  if (!BodySamples.empty()) {
164  OS << "Samples collected in the function's body {\n";
165  SampleSorter<LineLocation, SampleRecord> SortedBodySamples(BodySamples);
166  for (const auto &SI : SortedBodySamples.get()) {
167  OS.indent(Indent + 2);
168  OS << SI->first << ": " << SI->second;
169  }
170  OS.indent(Indent);
171  OS << "}\n";
172  } else {
173  OS << "No samples collected in the function's body\n";
174  }
175 
176  OS.indent(Indent);
177  if (!CallsiteSamples.empty()) {
178  OS << "Samples collected in inlined callsites {\n";
180  CallsiteSamples);
181  for (const auto &CS : SortedCallsiteSamples.get()) {
182  for (const auto &FS : CS->second) {
183  OS.indent(Indent + 2);
184  OS << CS->first << ": inlined callee: " << FS.second.getName() << ": ";
185  FS.second.print(OS, Indent + 4);
186  }
187  }
188  OS.indent(Indent);
189  OS << "}\n";
190  } else {
191  OS << "No inlined callsites in this function\n";
192  }
193 }
194 
196  const FunctionSamples &FS) {
197  FS.print(OS);
198  return OS;
199 }
200 
202  const SampleProfileMap &ProfileMap,
203  std::vector<NameFunctionSamples> &SortedProfiles) {
204  for (const auto &I : ProfileMap) {
205  assert(I.first == I.second.getContext() && "Inconsistent profile map");
206  SortedProfiles.push_back(std::make_pair(I.second.getContext(), &I.second));
207  }
208  llvm::stable_sort(SortedProfiles, [](const NameFunctionSamples &A,
209  const NameFunctionSamples &B) {
210  if (A.second->getTotalSamples() == B.second->getTotalSamples())
211  return A.first < B.first;
212  return A.second->getTotalSamples() > B.second->getTotalSamples();
213  });
214 }
215 
217  return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
218  0xffff;
219 }
220 
223  // In a pseudo-probe based profile, a callsite is simply represented by the
224  // ID of the probe associated with the call instruction. The probe ID is
225  // encoded in the Discriminator field of the call instruction's debug
226  // metadata.
228  DIL->getDiscriminator()),
229  0);
230  else
232  DIL->getBaseDiscriminator());
233 }
234 
236  const DILocation *DIL, SampleProfileReaderItaniumRemapper *Remapper) const {
237  assert(DIL);
239 
240  const DILocation *PrevDIL = DIL;
241  for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
242  unsigned Discriminator;
243  if (ProfileIsFS)
244  Discriminator = DIL->getDiscriminator();
245  else
246  Discriminator = DIL->getBaseDiscriminator();
247 
248  S.push_back(
249  std::make_pair(LineLocation(getOffset(DIL), Discriminator),
250  PrevDIL->getScope()->getSubprogram()->getLinkageName()));
251  PrevDIL = DIL;
252  }
253  if (S.size() == 0)
254  return this;
255  const FunctionSamples *FS = this;
256  for (int i = S.size() - 1; i >= 0 && FS != nullptr; i--) {
257  FS = FS->findFunctionSamplesAt(S[i].first, S[i].second, Remapper);
258  }
259  return FS;
260 }
261 
263  NameSet.insert(getName());
264  for (const auto &BS : BodySamples)
265  for (const auto &TS : BS.second.getCallTargets())
266  NameSet.insert(TS.getKey());
267 
268  for (const auto &CS : CallsiteSamples) {
269  for (const auto &NameFS : CS.second) {
270  NameSet.insert(NameFS.first);
271  NameFS.second.findAllNames(NameSet);
272  }
273  }
274 }
275 
277  const LineLocation &Loc, StringRef CalleeName,
278  SampleProfileReaderItaniumRemapper *Remapper) const {
279  CalleeName = getCanonicalFnName(CalleeName);
280 
281  std::string CalleeGUID;
282  CalleeName = getRepInFormat(CalleeName, UseMD5, CalleeGUID);
283 
284  auto iter = CallsiteSamples.find(Loc);
285  if (iter == CallsiteSamples.end())
286  return nullptr;
287  auto FS = iter->second.find(CalleeName);
288  if (FS != iter->second.end())
289  return &FS->second;
290  if (Remapper) {
291  if (auto NameInProfile = Remapper->lookUpNameInProfile(CalleeName)) {
292  auto FS = iter->second.find(*NameInProfile);
293  if (FS != iter->second.end())
294  return &FS->second;
295  }
296  }
297  // If we cannot find exact match of the callee name, return the FS with
298  // the max total count. Only do this when CalleeName is not provided,
299  // i.e., only for indirect calls.
300  if (!CalleeName.empty())
301  return nullptr;
302  uint64_t MaxTotalSamples = 0;
303  const FunctionSamples *R = nullptr;
304  for (const auto &NameFS : iter->second)
305  if (NameFS.second.getTotalSamples() >= MaxTotalSamples) {
306  MaxTotalSamples = NameFS.second.getTotalSamples();
307  R = &NameFS.second;
308  }
309  return R;
310 }
311 
312 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
314 #endif
315 
316 std::error_code ProfileSymbolList::read(const uint8_t *Data,
317  uint64_t ListSize) {
318  const char *ListStart = reinterpret_cast<const char *>(Data);
319  uint64_t Size = 0;
320  uint64_t StrNum = 0;
321  while (Size < ListSize && StrNum < ProfileSymbolListCutOff) {
322  StringRef Str(ListStart + Size);
323  add(Str);
324  Size += Str.size() + 1;
325  StrNum++;
326  }
327  if (Size != ListSize && StrNum != ProfileSymbolListCutOff)
330 }
331 
333  uint64_t ColdCountThreshold, bool TrimColdContext, bool MergeColdContext,
334  uint32_t ColdContextFrameLength) {
335  if (!TrimColdContext && !MergeColdContext)
336  return;
337 
338  // Nothing to merge if sample threshold is zero
339  if (ColdCountThreshold == 0)
340  return;
341 
342  // Filter the cold profiles from ProfileMap and move them into a tmp
343  // container
344  std::vector<std::pair<SampleContext, const FunctionSamples *>> ColdProfiles;
345  for (const auto &I : ProfileMap) {
346  const FunctionSamples &FunctionProfile = I.second;
347  if (FunctionProfile.getTotalSamples() >= ColdCountThreshold)
348  continue;
349  ColdProfiles.emplace_back(I.first, &I.second);
350  }
351 
352  // Remove the cold profile from ProfileMap and merge them into
353  // MergedProfileMap by the last K frames of context
354  SampleProfileMap MergedProfileMap;
355  for (const auto &I : ColdProfiles) {
356  if (MergeColdContext) {
357  auto MergedContext = I.second->getContext().getContextFrames();
358  if (ColdContextFrameLength < MergedContext.size())
359  MergedContext = MergedContext.take_back(ColdContextFrameLength);
360  auto Ret = MergedProfileMap.emplace(MergedContext, FunctionSamples());
361  FunctionSamples &MergedProfile = Ret.first->second;
362  MergedProfile.merge(*I.second);
363  }
364  ProfileMap.erase(I.first);
365  }
366 
367  // Move the merged profiles into ProfileMap;
368  for (const auto &I : MergedProfileMap) {
369  // Filter the cold merged profile
370  if (TrimColdContext && I.second.getTotalSamples() < ColdCountThreshold &&
371  ProfileMap.find(I.first) == ProfileMap.end())
372  continue;
373  // Merge the profile if the original profile exists, otherwise just insert
374  // as a new profile
375  auto Ret = ProfileMap.emplace(I.first, FunctionSamples());
376  if (Ret.second) {
377  SampleContext FContext(Ret.first->first, RawContext);
378  FunctionSamples &FProfile = Ret.first->second;
379  FProfile.setContext(FContext);
380  }
381  FunctionSamples &OrigProfile = Ret.first->second;
382  OrigProfile.merge(I.second);
383  }
384 }
385 
387  std::vector<SampleContext> ProfilesToBeRemoved;
388  SampleProfileMap ProfilesToBeAdded;
389  for (auto &I : ProfileMap) {
390  FunctionSamples &FProfile = I.second;
391  SampleContext &Context = FProfile.getContext();
392  if (I.first == Context)
393  continue;
394 
395  // Use the context string from FunctionSamples to update the keys of
396  // ProfileMap. They can get out of sync after context profile promotion
397  // through pre-inliner.
398  // Duplicate the function profile for later insertion to avoid a conflict
399  // caused by a context both to be add and to be removed. This could happen
400  // when a context is promoted to another context which is also promoted to
401  // the third context. For example, given an original context A @ B @ C that
402  // is promoted to B @ C and the original context B @ C which is promoted to
403  // just C, adding B @ C to the profile map while removing same context (but
404  // with different profiles) from the map can cause a conflict if they are
405  // not handled in a right order. This can be solved by just caching the
406  // profiles to be added.
407  auto Ret = ProfilesToBeAdded.emplace(Context, FProfile);
408  (void)Ret;
409  assert(Ret.second && "Context conflict during canonicalization");
410  ProfilesToBeRemoved.push_back(I.first);
411  }
412 
413  for (auto &I : ProfilesToBeRemoved) {
414  ProfileMap.erase(I);
415  }
416 
417  for (auto &I : ProfilesToBeAdded) {
418  ProfileMap.emplace(I.first, I.second);
419  }
420 }
421 
422 std::error_code ProfileSymbolList::write(raw_ostream &OS) {
423  // Sort the symbols before output. If doing compression.
424  // It will make the compression much more effective.
425  std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
426  llvm::sort(SortedList);
427 
428  std::string OutputString;
429  for (auto &Sym : SortedList) {
430  OutputString.append(Sym.str());
431  OutputString.append(1, '\0');
432  }
433 
434  OS << OutputString;
436 }
437 
439  OS << "======== Dump profile symbol list ========\n";
440  std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
441  llvm::sort(SortedList);
442 
443  for (auto &Sym : SortedList)
444  OS << Sym << "\n";
445 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
i
i
Definition: README.txt:29
llvm::sampleprof_error::uncompress_failed
@ uncompress_failed
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:491
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::sampleprof::SampleSorter::get
const SamplesWithLocList & get() const
Definition: SampleProf.h:1115
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::sampleprof::FunctionSamples::ProfileIsProbeBased
static bool ProfileIsProbeBased
Definition: SampleProf.h:1010
llvm::sampleprof::FunctionSamples::dump
void dump() const
Definition: SampleProf.cpp:313
llvm::sampleprof::FunctionSamples::ProfileIsCS
static bool ProfileIsCS
Definition: SampleProf.h:1012
llvm::sampleprof::RawContext
@ RawContext
Definition: SampleProf.h:402
DebugInfoMetadata.h
llvm::sampleprof::LineLocation::dump
void dump() const
Definition: SampleProf.cpp:130
ErrorCategory
static ManagedStatic< SampleProfErrorCategoryType > ErrorCategory
Definition: SampleProf.cpp:99
llvm::sampleprof::SampleRecord::hasCalls
bool hasCalls() const
Return true if this sample record contains function calls.
Definition: SampleProf.h:359
llvm::sampleprof_error::hash_mismatch
@ hash_mismatch
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::sampleprof::NameFunctionSamples
std::pair< SampleContext, const FunctionSamples * > NameFunctionSamples
Definition: SampleProf.h:1093
ErrorHandling.h
ManagedStatic.h
Error.h
llvm::sampleprof_error::unsupported_version
@ unsupported_version
llvm::sampleprof::SampleProfileMap
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
Definition: SampleProf.h:1091
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1580
llvm::sampleprof_error::not_implemented
@ not_implemented
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::sampleprof::FunctionSamples::findAllNames
void findAllNames(DenseSet< StringRef > &NameSet) const
Definition: SampleProf.cpp:262
llvm::sampleprof::FunctionSamples::getName
StringRef getName() const
Return the function name.
Definition: SampleProf.h:915
llvm::sampleprof::MergedContext
@ MergedContext
Definition: SampleProf.h:405
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::sampleprof::LineLocation::Discriminator
uint32_t Discriminator
Definition: SampleProf.h:300
llvm::sampleprof_error::counter_overflow
@ counter_overflow
llvm::sampleprof::LineLocation::LineOffset
uint32_t LineOffset
Definition: SampleProf.h:299
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::sampleprof::FunctionSamples::HasUniqSuffix
static bool HasUniqSuffix
Whether the profile contains any ".__uniq." suffix in a name.
Definition: SampleProf.h:1024
CommandLine.h
llvm::sampleprof_error::unsupported_writing_format
@ unsupported_writing_format
llvm::sampleprof::SampleProfileFormat
SampleProfileFormat
Definition: SampleProf.h:90
llvm::sampleprof::getRepInFormat
static StringRef getRepInFormat(StringRef Name, bool UseMD5, std::string &GUIDBuf)
Get the proper representation of a string according to whether the current Format uses MD5 to represe...
Definition: SampleProf.h:108
llvm::sampleprof::FunctionSamples::getTotalSamples
uint64_t getTotalSamples() const
Return the total number of samples collected inside the function.
Definition: SampleProf.h:789
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ManagedStatic
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
SampleProf.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::sampleprof::SampleProfileReaderItaniumRemapper::lookUpNameInProfile
Optional< StringRef > lookUpNameInProfile(StringRef FunctionName)
Return the equivalent name in the profile for FunctionName if it exists.
Definition: SampleProfReader.cpp:1690
llvm::sampleprof_category
const std::error_category & sampleprof_category()
Definition: SampleProf.cpp:101
llvm::sampleprof::FunctionSamples::Format
static SampleProfileFormat Format
Definition: SampleProf.h:1018
ColdCountThreshold
static cl::opt< unsigned > ColdCountThreshold("mfs-count-threshold", cl::desc("Minimum number of times a block must be executed to be retained."), cl::init(1), cl::Hidden)
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::sampleprof::ProfileSymbolList::read
std::error_code read(const uint8_t *Data, uint64_t ListSize)
Definition: SampleProf.cpp:316
llvm::sampleprof::SampleContext
Definition: SampleProf.h:469
llvm::sampleprof::sortFuncProfiles
void sortFuncProfiles(const SampleProfileMap &ProfileMap, std::vector< NameFunctionSamples > &SortedProfiles)
Definition: SampleProf.cpp:201
llvm::sampleprof::FunctionSamples::ProfileIsFS
static bool ProfileIsFS
If this profile uses flow sensitive discriminators.
Definition: SampleProf.h:1027
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
llvm::cl::ZeroOrMore
@ ZeroOrMore
Definition: CommandLine.h:120
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::cl::opt
Definition: CommandLine.h:1434
uint64_t
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:684
LEB128.h
I
#define I(x, y, z)
Definition: MD5.cpp:59
SampleProfReader.h
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::sampleprof::FunctionSamples::setContext
void setContext(const SampleContext &FContext)
Definition: SampleProf.h:1016
llvm::sampleprof::FunctionSamples::getFunctionHash
uint64_t getFunctionHash() const
Definition: SampleProf.h:922
llvm::sampleprof::SampleRecord::getSortedCallTargets
const SortedCallTargetSet getSortedCallTargets() const
Definition: SampleProf.h:363
llvm::sampleprof_error::malformed
@ malformed
message
message(STATUS "Targeting ${t}") add_subdirectory($
Definition: CMakeLists.txt:33
llvm::sampleprof::FunctionSamples::getCallSiteIdentifier
static LineLocation getCallSiteIdentifier(const DILocation *DIL)
Returns a unique call site identifier for a given debug location of a call instruction.
Definition: SampleProf.cpp:221
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::sampleprof::operator<<
raw_ostream & operator<<(raw_ostream &OS, const LineLocation &Loc)
Definition: SampleProf.cpp:111
llvm::sampleprof::FunctionSamples::UseMD5
static bool UseMD5
Whether the profile uses MD5 to represent string.
Definition: SampleProf.h:1021
llvm::PseudoProbeDwarfDiscriminator::extractProbeIndex
static uint32_t extractProbeIndex(uint32_t Value)
Definition: PseudoProbe.h:54
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::sampleprof::FunctionSamples::getOffset
static unsigned getOffset(const DILocation *DIL)
Returns the line offset to the start line of the subprogram.
Definition: SampleProf.cpp:216
llvm::sampleprof::LineLocation
Represents the relative location of an instruction.
Definition: SampleProf.h:280
llvm::MergeResult
sampleprof_error MergeResult(sampleprof_error &Accumulator, sampleprof_error Result)
Definition: SampleProf.h:68
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::sampleprof::SampleSorter
Sort a LocationT->SampleT map by LocationT.
Definition: SampleProf.h:1102
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::sampleprof_error::unrecognized_format
@ unrecognized_format
uint32_t
Compiler.h
llvm::sampleprof::ProfileSymbolList::add
void add(StringRef Name, bool copy=false)
copy indicates whether we need to copy the underlying memory for the input Name.
Definition: SampleProf.h:1147
llvm::sampleprof::FunctionSamples::print
void print(raw_ostream &OS=dbgs(), unsigned Indent=0) const
Print the samples collected for a function on stream OS.
Definition: SampleProf.cpp:155
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::sampleprof::FunctionSamples::findFunctionSamplesAt
const FunctionSamples * findFunctionSamplesAt(const LineLocation &Loc, StringRef CalleeName, SampleProfileReaderItaniumRemapper *Remapper) const
Returns a pointer to FunctionSamples at the given callsite location Loc with callee CalleeName.
Definition: SampleProf.cpp:276
llvm::sampleprof_error::ostream_seek_unsupported
@ ostream_seek_unsupported
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:78
llvm::stable_sort
void stable_sort(R &&Range)
Definition: STLExtras.h:1682
llvm::sampleprof::SampleContextTrimmer::trimAndMergeColdContextProfiles
void trimAndMergeColdContextProfiles(uint64_t ColdCountThreshold, bool TrimColdContext, bool MergeColdContext, uint32_t ColdContextFrameLength)
Definition: SampleProf.cpp:332
llvm::sampleprof::ProfileSymbolList::write
std::error_code write(raw_ostream &OS)
Definition: SampleProf.cpp:422
llvm::sampleprof::LineLocation::print
void print(raw_ostream &OS) const
Definition: SampleProf.cpp:105
llvm::sampleprof::SampleRecord::print
void print(raw_ostream &OS, unsigned Indent) const
Print the sample record to the stream OS indented by Indent.
Definition: SampleProf.cpp:134
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1488
llvm::sampleprof::SampleRecord
Representation of a single sample record.
Definition: SampleProf.h:315
llvm::sampleprof_error::compress_failed
@ compress_failed
PseudoProbe.h
llvm::sampleprof_error
sampleprof_error
Definition: SampleProf.h:45
llvm::sampleprof::FunctionSamples::merge
sampleprof_error merge(const FunctionSamples &Other, uint64_t Weight=1)
Merge the samples in Other into this one.
Definition: SampleProf.h:845
llvm::sampleprof_error::zlib_unavailable
@ zlib_unavailable
llvm::sampleprof_error::too_large
@ too_large
llvm::sampleprof::SampleRecord::addCalledTarget
sampleprof_error addCalledTarget(StringRef F, uint64_t S, uint64_t Weight=1)
Add called function F with samples S.
Definition: SampleProf.h:348
llvm::sampleprof::FunctionSamples::getContext
SampleContext & getContext() const
Definition: SampleProf.h:1014
llvm::sampleprof_error::success
@ success
llvm::sampleprof::FunctionSamples::getCanonicalFnName
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
Definition: SampleProf.h:926
llvm::DILocation::getBaseDiscriminator
unsigned getBaseDiscriminator() const
Returns the base discriminator stored in the discriminator.
Definition: DebugInfoMetadata.h:2229
llvm::sampleprof::SampleContextTrimmer::canonicalizeContextProfiles
void canonicalizeContextProfiles()
Definition: SampleProf.cpp:386
llvm::sampleprof::SampleRecord::dump
void dump() const
Definition: SampleProf.cpp:145
llvm::raw_ostream::indent
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
Definition: raw_ostream.cpp:497
llvm::sampleprof::SampleRecord::merge
sampleprof_error merge(const SampleRecord &Other, uint64_t Weight=1)
Merge the samples in Other into this record.
Definition: SampleProf.cpp:119
llvm::sampleprof::SampleProfileReaderItaniumRemapper
SampleProfileReaderItaniumRemapper remaps the profile data from a sample profile data reader,...
Definition: SampleProfReader.h:264
llvm::sampleprof_error::truncated_name_table
@ truncated_name_table
llvm::sampleprof::ProfileSymbolList::dump
void dump(raw_ostream &OS=dbgs()) const
Definition: SampleProf.cpp:438
ProfileSymbolListCutOff
static cl::opt< uint64_t > ProfileSymbolListCutOff("profile-symbol-list-cutoff", cl::Hidden, cl::init(-1), cl::ZeroOrMore, cl::desc("Cutoff value about how many symbols in profile symbol list " "will be used. This is very useful for performance debugging"))
llvm::cl::desc
Definition: CommandLine.h:414
raw_ostream.h
error_category
static ManagedStatic< _object_error_category > error_category
Definition: Error.cpp:76
llvm::sampleprof_error::truncated
@ truncated
Debug.h
llvm::sampleprof::SampleRecord::addSamples
sampleprof_error addSamples(uint64_t S, uint64_t Weight=1)
Increment the number of samples for this record by S.
Definition: SampleProf.h:336
llvm::sampleprof_error::bad_magic
@ bad_magic
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::sampleprof::FunctionSamples::findFunctionSamples
const FunctionSamples * findFunctionSamples(const DILocation *DIL, SampleProfileReaderItaniumRemapper *Remapper=nullptr) const
Get the FunctionSamples of the inline instance where DIL originates from.
Definition: SampleProf.cpp:235