LLVM  16.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"
24 #include <string>
25 #include <system_error>
26 
27 using namespace llvm;
28 using namespace sampleprof;
29 
31  "profile-symbol-list-cutoff", cl::Hidden, cl::init(-1),
32  cl::desc("Cutoff value about how many symbols in profile symbol list "
33  "will be used. This is very useful for performance debugging"));
34 
36  "generate-merged-base-profiles",
37  cl::desc("When generating nested context-sensitive profiles, always "
38  "generate extra base profile for function with all its context "
39  "profiles merged into it."));
40 
41 namespace llvm {
42 namespace sampleprof {
44 bool FunctionSamples::ProfileIsCS = false;
46 bool FunctionSamples::UseMD5 = false;
48 bool FunctionSamples::ProfileIsFS = false;
49 } // namespace sampleprof
50 } // namespace llvm
51 
52 namespace {
53 
54 // FIXME: This class is only here to support the transition to llvm::Error. It
55 // will be removed once this transition is complete. Clients should prefer to
56 // deal with the Error value directly, rather than converting to error_code.
57 class SampleProfErrorCategoryType : public std::error_category {
58  const char *name() const noexcept override { return "llvm.sampleprof"; }
59 
60  std::string message(int IE) const override {
61  sampleprof_error E = static_cast<sampleprof_error>(IE);
62  switch (E) {
64  return "Success";
66  return "Invalid sample profile data (bad magic)";
68  return "Unsupported sample profile format version";
70  return "Too much profile data";
72  return "Truncated profile data";
74  return "Malformed sample profile data";
76  return "Unrecognized sample profile encoding format";
78  return "Profile encoding format unsupported for writing operations";
80  return "Truncated function name table";
82  return "Unimplemented feature";
84  return "Counter overflow";
86  return "Ostream does not support seek";
88  return "Uncompress failure";
90  return "Zlib is unavailable";
92  return "Function hash mismatch";
93  }
94  llvm_unreachable("A value of sampleprof_error has no message.");
95  }
96 };
97 
98 } // end anonymous namespace
99 
100 const std::error_category &llvm::sampleprof_category() {
101  static SampleProfErrorCategoryType ErrorCategory;
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 
222  bool ProfileIsFS) {
224  // In a pseudo-probe based profile, a callsite is simply represented by the
225  // ID of the probe associated with the call instruction. The probe ID is
226  // encoded in the Discriminator field of the call instruction's debug
227  // metadata.
229  DIL->getDiscriminator()),
230  0);
231  } else {
232  unsigned Discriminator =
233  ProfileIsFS ? DIL->getDiscriminator() : DIL->getBaseDiscriminator();
234  return LineLocation(FunctionSamples::getOffset(DIL), Discriminator);
235  }
236 }
237 
239  const LineLocation &Callsite) {
240  uint64_t NameHash = std::hash<std::string>{}(CalleeName.str());
241  uint64_t LocId =
242  (((uint64_t)Callsite.LineOffset) << 32) | Callsite.Discriminator;
243  return NameHash + (LocId << 5) + LocId;
244 }
245 
247  const DILocation *DIL, SampleProfileReaderItaniumRemapper *Remapper) const {
248  assert(DIL);
250 
251  const DILocation *PrevDIL = DIL;
252  for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
253  // Use C++ linkage name if possible.
254  StringRef Name = PrevDIL->getScope()->getSubprogram()->getLinkageName();
255  if (Name.empty())
256  Name = PrevDIL->getScope()->getSubprogram()->getName();
259  Name);
260  PrevDIL = DIL;
261  }
262 
263  if (S.size() == 0)
264  return this;
265  const FunctionSamples *FS = this;
266  for (int i = S.size() - 1; i >= 0 && FS != nullptr; i--) {
267  FS = FS->findFunctionSamplesAt(S[i].first, S[i].second, Remapper);
268  }
269  return FS;
270 }
271 
273  NameSet.insert(getName());
274  for (const auto &BS : BodySamples)
275  for (const auto &TS : BS.second.getCallTargets())
276  NameSet.insert(TS.getKey());
277 
278  for (const auto &CS : CallsiteSamples) {
279  for (const auto &NameFS : CS.second) {
280  NameSet.insert(NameFS.first);
281  NameFS.second.findAllNames(NameSet);
282  }
283  }
284 }
285 
287  const LineLocation &Loc, StringRef CalleeName,
288  SampleProfileReaderItaniumRemapper *Remapper) const {
289  CalleeName = getCanonicalFnName(CalleeName);
290 
291  std::string CalleeGUID;
292  CalleeName = getRepInFormat(CalleeName, UseMD5, CalleeGUID);
293 
294  auto iter = CallsiteSamples.find(Loc);
295  if (iter == CallsiteSamples.end())
296  return nullptr;
297  auto FS = iter->second.find(CalleeName);
298  if (FS != iter->second.end())
299  return &FS->second;
300  if (Remapper) {
301  if (auto NameInProfile = Remapper->lookUpNameInProfile(CalleeName)) {
302  auto FS = iter->second.find(*NameInProfile);
303  if (FS != iter->second.end())
304  return &FS->second;
305  }
306  }
307  // If we cannot find exact match of the callee name, return the FS with
308  // the max total count. Only do this when CalleeName is not provided,
309  // i.e., only for indirect calls.
310  if (!CalleeName.empty())
311  return nullptr;
312  uint64_t MaxTotalSamples = 0;
313  const FunctionSamples *R = nullptr;
314  for (const auto &NameFS : iter->second)
315  if (NameFS.second.getTotalSamples() >= MaxTotalSamples) {
316  MaxTotalSamples = NameFS.second.getTotalSamples();
317  R = &NameFS.second;
318  }
319  return R;
320 }
321 
322 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
324 #endif
325 
326 std::error_code ProfileSymbolList::read(const uint8_t *Data,
327  uint64_t ListSize) {
328  const char *ListStart = reinterpret_cast<const char *>(Data);
329  uint64_t Size = 0;
330  uint64_t StrNum = 0;
331  while (Size < ListSize && StrNum < ProfileSymbolListCutOff) {
332  StringRef Str(ListStart + Size);
333  add(Str);
334  Size += Str.size() + 1;
335  StrNum++;
336  }
337  if (Size != ListSize && StrNum != ProfileSymbolListCutOff)
340 }
341 
343  uint64_t ColdCountThreshold, bool TrimColdContext, bool MergeColdContext,
344  uint32_t ColdContextFrameLength, bool TrimBaseProfileOnly) {
345  if (!TrimColdContext && !MergeColdContext)
346  return;
347 
348  // Nothing to merge if sample threshold is zero
349  if (ColdCountThreshold == 0)
350  return;
351 
352  // Trimming base profiles only is mainly to honor the preinliner decsion. When
353  // MergeColdContext is true preinliner decsion is not honored anyway so turn
354  // off TrimBaseProfileOnly.
355  if (MergeColdContext)
356  TrimBaseProfileOnly = false;
357 
358  // Filter the cold profiles from ProfileMap and move them into a tmp
359  // container
360  std::vector<std::pair<SampleContext, const FunctionSamples *>> ColdProfiles;
361  for (const auto &I : ProfileMap) {
362  const SampleContext &Context = I.first;
363  const FunctionSamples &FunctionProfile = I.second;
364  if (FunctionProfile.getTotalSamples() < ColdCountThreshold &&
365  (!TrimBaseProfileOnly || Context.isBaseContext()))
366  ColdProfiles.emplace_back(Context, &I.second);
367  }
368 
369  // Remove the cold profile from ProfileMap and merge them into
370  // MergedProfileMap by the last K frames of context
371  SampleProfileMap MergedProfileMap;
372  for (const auto &I : ColdProfiles) {
373  if (MergeColdContext) {
374  auto MergedContext = I.second->getContext().getContextFrames();
375  if (ColdContextFrameLength < MergedContext.size())
376  MergedContext = MergedContext.take_back(ColdContextFrameLength);
377  auto Ret = MergedProfileMap.emplace(MergedContext, FunctionSamples());
378  FunctionSamples &MergedProfile = Ret.first->second;
379  MergedProfile.merge(*I.second);
380  }
381  ProfileMap.erase(I.first);
382  }
383 
384  // Move the merged profiles into ProfileMap;
385  for (const auto &I : MergedProfileMap) {
386  // Filter the cold merged profile
387  if (TrimColdContext && I.second.getTotalSamples() < ColdCountThreshold &&
388  ProfileMap.find(I.first) == ProfileMap.end())
389  continue;
390  // Merge the profile if the original profile exists, otherwise just insert
391  // as a new profile
392  auto Ret = ProfileMap.emplace(I.first, FunctionSamples());
393  if (Ret.second) {
394  SampleContext FContext(Ret.first->first, RawContext);
395  FunctionSamples &FProfile = Ret.first->second;
396  FProfile.setContext(FContext);
397  }
398  FunctionSamples &OrigProfile = Ret.first->second;
399  OrigProfile.merge(I.second);
400  }
401 }
402 
404  std::vector<SampleContext> ProfilesToBeRemoved;
405  SampleProfileMap ProfilesToBeAdded;
406  for (auto &I : ProfileMap) {
407  FunctionSamples &FProfile = I.second;
408  SampleContext &Context = FProfile.getContext();
409  if (I.first == Context)
410  continue;
411 
412  // Use the context string from FunctionSamples to update the keys of
413  // ProfileMap. They can get out of sync after context profile promotion
414  // through pre-inliner.
415  // Duplicate the function profile for later insertion to avoid a conflict
416  // caused by a context both to be add and to be removed. This could happen
417  // when a context is promoted to another context which is also promoted to
418  // the third context. For example, given an original context A @ B @ C that
419  // is promoted to B @ C and the original context B @ C which is promoted to
420  // just C, adding B @ C to the profile map while removing same context (but
421  // with different profiles) from the map can cause a conflict if they are
422  // not handled in a right order. This can be solved by just caching the
423  // profiles to be added.
424  auto Ret = ProfilesToBeAdded.emplace(Context, FProfile);
425  (void)Ret;
426  assert(Ret.second && "Context conflict during canonicalization");
427  ProfilesToBeRemoved.push_back(I.first);
428  }
429 
430  for (auto &I : ProfilesToBeRemoved) {
431  ProfileMap.erase(I);
432  }
433 
434  for (auto &I : ProfilesToBeAdded) {
435  ProfileMap.emplace(I.first, I.second);
436  }
437 }
438 
439 std::error_code ProfileSymbolList::write(raw_ostream &OS) {
440  // Sort the symbols before output. If doing compression.
441  // It will make the compression much more effective.
442  std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
443  llvm::sort(SortedList);
444 
445  std::string OutputString;
446  for (auto &Sym : SortedList) {
447  OutputString.append(Sym.str());
448  OutputString.append(1, '\0');
449  }
450 
451  OS << OutputString;
453 }
454 
456  OS << "======== Dump profile symbol list ========\n";
457  std::vector<StringRef> SortedList(Syms.begin(), Syms.end());
458  llvm::sort(SortedList);
459 
460  for (auto &Sym : SortedList)
461  OS << Sym << "\n";
462 }
463 
466  const LineLocation &CallSite, StringRef CalleeName) {
467  uint64_t Hash = FunctionSamples::getCallSiteHash(CalleeName, CallSite);
468  auto It = AllChildFrames.find(Hash);
469  if (It != AllChildFrames.end()) {
470  assert(It->second.FuncName == CalleeName &&
471  "Hash collision for child context node");
472  return &It->second;
473  }
474 
475  AllChildFrames[Hash] = FrameNode(CalleeName, nullptr, CallSite);
476  return &AllChildFrames[Hash];
477 }
478 
480  : ProfileMap(Profiles) {
481  for (auto &FuncSample : Profiles) {
482  FunctionSamples *FSamples = &FuncSample.second;
483  auto *NewNode = getOrCreateContextPath(FSamples->getContext());
484  assert(!NewNode->FuncSamples && "New node cannot have sample profile");
485  NewNode->FuncSamples = FSamples;
486  }
487 }
488 
490 CSProfileConverter::getOrCreateContextPath(const SampleContext &Context) {
491  auto Node = &RootFrame;
492  LineLocation CallSiteLoc(0, 0);
493  for (auto &Callsite : Context.getContextFrames()) {
494  Node = Node->getOrCreateChildFrame(CallSiteLoc, Callsite.FuncName);
495  CallSiteLoc = Callsite.Location;
496  }
497  return Node;
498 }
499 
501  // Process each child profile. Add each child profile to callsite profile map
502  // of the current node `Node` if `Node` comes with a profile. Otherwise
503  // promote the child profile to a standalone profile.
504  auto *NodeProfile = Node.FuncSamples;
505  for (auto &It : Node.AllChildFrames) {
506  auto &ChildNode = It.second;
507  convertProfiles(ChildNode);
508  auto *ChildProfile = ChildNode.FuncSamples;
509  if (!ChildProfile)
510  continue;
511  SampleContext OrigChildContext = ChildProfile->getContext();
512  // Reset the child context to be contextless.
513  ChildProfile->getContext().setName(OrigChildContext.getName());
514  if (NodeProfile) {
515  // Add child profile to the callsite profile map.
516  auto &SamplesMap = NodeProfile->functionSamplesAt(ChildNode.CallSiteLoc);
517  SamplesMap.emplace(OrigChildContext.getName().str(), *ChildProfile);
518  NodeProfile->addTotalSamples(ChildProfile->getTotalSamples());
519  // Remove the corresponding body sample for the callsite and update the
520  // total weight.
521  auto Count = NodeProfile->removeCalledTargetAndBodySample(
522  ChildNode.CallSiteLoc.LineOffset, ChildNode.CallSiteLoc.Discriminator,
523  OrigChildContext.getName());
524  NodeProfile->removeTotalSamples(Count);
525  }
526 
527  // Separate child profile to be a standalone profile, if the current parent
528  // profile doesn't exist. This is a duplicating operation when the child
529  // profile is already incorporated into the parent which is still useful and
530  // thus done optionally. It is seen that duplicating context profiles into
531  // base profiles improves the code quality for thinlto build by allowing a
532  // profile in the prelink phase for to-be-fully-inlined functions.
533  if (!NodeProfile) {
534  ProfileMap[ChildProfile->getContext()].merge(*ChildProfile);
535  } else if (GenerateMergedBaseProfiles) {
536  ProfileMap[ChildProfile->getContext()].merge(*ChildProfile);
537  auto &SamplesMap = NodeProfile->functionSamplesAt(ChildNode.CallSiteLoc);
538  SamplesMap[ChildProfile->getName().str()].getContext().setAttribute(
540  }
541 
542  // Remove the original child profile.
543  ProfileMap.erase(OrigChildContext);
544  }
545 }
546 
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:492
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::sampleprof::SampleSorter::get
const SamplesWithLocList & get() const
Definition: SampleProf.h:1223
llvm::sampleprof::ContextDuplicatedIntoBase
@ ContextDuplicatedIntoBase
Definition: SampleProf.h:451
llvm::sampleprof::FunctionSamples::ProfileIsProbeBased
static bool ProfileIsProbeBased
Definition: SampleProf.h:1118
llvm::sampleprof::FunctionSamples::dump
void dump() const
Definition: SampleProf.cpp:323
llvm::sampleprof::FunctionSamples::ProfileIsCS
static bool ProfileIsCS
Definition: SampleProf.h:1120
llvm::sampleprof::RawContext
@ RawContext
Definition: SampleProf.h:440
DebugInfoMetadata.h
llvm::sampleprof::LineLocation::dump
void dump() const
Definition: SampleProf.cpp:130
name
static const char * name
Definition: SMEABIPass.cpp:49
llvm::sampleprof::SampleRecord::hasCalls
bool hasCalls() const
Return true if this sample record contains function calls.
Definition: SampleProf.h:390
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:1199
llvm::sampleprof::NameFunctionSamples
std::pair< SampleContext, const FunctionSamples * > NameFunctionSamples
Definition: SampleProf.h:1201
ErrorHandling.h
llvm::sampleprof_error::unsupported_version
@ unsupported_version
llvm::sampleprof::SampleProfileMap
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
Definition: SampleProf.h:1199
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1595
llvm::sampleprof_error::not_implemented
@ not_implemented
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::sampleprof::FunctionSamples::findAllNames
void findAllNames(DenseSet< StringRef > &NameSet) const
Definition: SampleProf.cpp:272
llvm::sampleprof::FunctionSamples::getName
StringRef getName() const
Return the function name.
Definition: SampleProf.h:1017
llvm::sampleprof::MergedContext
@ MergedContext
Definition: SampleProf.h:443
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::sampleprof::CSProfileConverter::FrameNode::getOrCreateChildFrame
FrameNode * getOrCreateChildFrame(const LineLocation &CallSite, StringRef CalleeName)
Definition: SampleProf.cpp:465
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::sampleprof::LineLocation::Discriminator
uint32_t Discriminator
Definition: SampleProf.h:303
GenerateMergedBaseProfiles
cl::opt< bool > GenerateMergedBaseProfiles("generate-merged-base-profiles", cl::desc("When generating nested context-sensitive profiles, always " "generate extra base profile for function with all its context " "profiles merged into it."))
llvm::sampleprof_error::counter_overflow
@ counter_overflow
llvm::sampleprof::LineLocation::LineOffset
uint32_t LineOffset
Definition: SampleProf.h:302
ProfileSymbolListCutOff
static cl::opt< uint64_t > ProfileSymbolListCutOff("profile-symbol-list-cutoff", cl::Hidden, cl::init(-1), cl::desc("Cutoff value about how many symbols in profile symbol list " "will be used. This is very useful for performance debugging"))
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:1132
CommandLine.h
llvm::sampleprof_error::unsupported_writing_format
@ unsupported_writing_format
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:883
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::sampleprof::CSProfileConverter::FrameNode
Definition: SampleProf.h:1260
SI
@ SI
Definition: SIInstrInfo.cpp:7966
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:1824
llvm::sampleprof_category
const std::error_category & sampleprof_category()
Definition: SampleProf.cpp:100
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::X86AS::FS
@ FS
Definition: X86.h:200
llvm::sampleprof::ProfileSymbolList::read
std::error_code read(const uint8_t *Data, uint64_t ListSize)
Definition: SampleProf.cpp:326
llvm::sampleprof::CSProfileConverter::FrameNode::AllChildFrames
std::map< uint64_t, FrameNode > AllChildFrames
Definition: SampleProf.h:1264
llvm::sampleprof::SampleContext
Definition: SampleProf.h:509
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:1135
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1682
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::cl::opt
Definition: CommandLine.h:1412
llvm::sampleprof::SampleContext::setName
void setName(StringRef FunctionName)
Set the name of the function and clear the current context.
Definition: SampleProf.h:625
uint64_t
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:718
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::sampleprof::FunctionSamples::getCallSiteHash
static uint64_t getCallSiteHash(StringRef CalleeName, const LineLocation &Callsite)
Returns a unique hash code for a combination of a callsite location and the callee function name.
Definition: SampleProf.cpp:238
SampleProfReader.h
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:447
llvm::sampleprof::FunctionSamples::setContext
void setContext(const SampleContext &FContext)
Definition: SampleProf.h:1126
llvm::sampleprof::FunctionSamples::getFunctionHash
uint64_t getFunctionHash() const
Definition: SampleProf.h:1024
llvm::sampleprof::SampleRecord::getSortedCallTargets
const SortedCallTargetSet getSortedCallTargets() const
Definition: SampleProf.h:394
llvm::sampleprof_error::malformed
@ malformed
message
message(STATUS "Targeting ${t}") add_subdirectory($
Definition: CMakeLists.txt:34
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::sampleprof::SampleContext::getName
StringRef getName() const
Definition: SampleProf.h:597
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:1129
llvm::PseudoProbeDwarfDiscriminator::extractProbeIndex
static uint32_t extractProbeIndex(uint32_t Value)
Definition: PseudoProbe.h:60
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:283
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:50
llvm::sampleprof::SampleSorter
Sort a LocationT->SampleT map by LocationT.
Definition: SampleProf.h:1210
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
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:1296
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:286
llvm::sampleprof_error::ostream_seek_unsupported
@ ostream_seek_unsupported
llvm::sampleprof::CSProfileConverter::convertProfiles
void convertProfiles()
Definition: SampleProf.cpp:547
llvm::stable_sort
void stable_sort(R &&Range)
Definition: STLExtras.h:1947
llvm::sampleprof::ProfileSymbolList::write
std::error_code write(raw_ostream &OS)
Definition: SampleProf.cpp:439
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::sampleprof::SampleRecord
Representation of a single sample record.
Definition: SampleProf.h:325
llvm::sampleprof::CSProfileConverter::FrameNode::FrameNode
FrameNode(StringRef FName=StringRef(), FunctionSamples *FSamples=nullptr, LineLocation CallLoc={0, 0})
Definition: SampleProf.h:1261
PseudoProbe.h
llvm::sampleprof_error
sampleprof_error
Definition: SampleProf.h:46
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:947
llvm::sampleprof_error::zlib_unavailable
@ zlib_unavailable
llvm::sampleprof_error::too_large
@ too_large
llvm::sampleprof::SampleContextTrimmer::trimAndMergeColdContextProfiles
void trimAndMergeColdContextProfiles(uint64_t ColdCountThreshold, bool TrimColdContext, bool MergeColdContext, uint32_t ColdContextFrameLength, bool TrimBaseProfileOnly)
Definition: SampleProf.cpp:342
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:367
llvm::sampleprof::FunctionSamples::getContext
SampleContext & getContext() const
Definition: SampleProf.h:1124
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:1028
llvm::DILocation::getBaseDiscriminator
unsigned getBaseDiscriminator() const
Returns the base discriminator stored in the discriminator.
Definition: DebugInfoMetadata.h:2249
llvm::sampleprof::SampleContextTrimmer::canonicalizeContextProfiles
void canonicalizeContextProfiles()
Definition: SampleProf.cpp:403
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:494
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::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:221
llvm::sampleprof::SampleProfileReaderItaniumRemapper
SampleProfileReaderItaniumRemapper remaps the profile data from a sample profile data reader,...
Definition: SampleProfReader.h:261
llvm::sampleprof_error::truncated_name_table
@ truncated_name_table
llvm::sampleprof::ProfileSymbolList::dump
void dump(raw_ostream &OS=dbgs()) const
Definition: SampleProf.cpp:455
llvm::cl::desc
Definition: CommandLine.h:413
raw_ostream.h
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:346
llvm::sampleprof_error::bad_magic
@ bad_magic
llvm::sampleprof::CSProfileConverter::CSProfileConverter
CSProfileConverter(SampleProfileMap &Profiles)
Definition: SampleProf.cpp:479
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1251
llvm::sampleprof::FunctionSamples::getCallSiteIdentifier
static LineLocation getCallSiteIdentifier(const DILocation *DIL, bool ProfileIsFS=false)
Returns a unique call site identifier for a given debug location of a call instruction.
Definition: SampleProf.cpp:221
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:246
llvm::sampleprof::FunctionSamples::ProfileIsPreInlined
static bool ProfileIsPreInlined
Definition: SampleProf.h:1122