LLVM  14.0.0git
SampleProfWriter.cpp
Go to the documentation of this file.
1 //===- SampleProfWriter.cpp - Write LLVM sample profile data --------------===//
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 implements the class that writes LLVM sample profiles. It
10 // supports two file formats: text and binary. The textual representation
11 // is useful for debugging and testing purposes. The binary representation
12 // is more compact, resulting in smaller file sizes. However, they can
13 // both be used interchangeably.
14 //
15 // See lib/ProfileData/SampleProfReader.cpp for documentation on each of the
16 // supported formats.
17 //
18 //===----------------------------------------------------------------------===//
19 
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/StringSet.h"
26 #include "llvm/Support/Endian.h"
28 #include "llvm/Support/ErrorOr.h"
30 #include "llvm/Support/LEB128.h"
31 #include "llvm/Support/MD5.h"
33 #include <algorithm>
34 #include <cstdint>
35 #include <memory>
36 #include <set>
37 #include <system_error>
38 #include <utility>
39 #include <vector>
40 
41 using namespace llvm;
42 using namespace sampleprof;
43 
44 std::error_code
46  std::vector<NameFunctionSamples> V;
47  sortFuncProfiles(ProfileMap, V);
48  for (const auto &I : V) {
49  if (std::error_code EC = writeSample(*I.second))
50  return EC;
51  }
53 }
54 
55 std::error_code SampleProfileWriter::write(const SampleProfileMap &ProfileMap) {
56  if (std::error_code EC = writeHeader(ProfileMap))
57  return EC;
58 
59  if (std::error_code EC = writeFuncProfiles(ProfileMap))
60  return EC;
61 
63 }
64 
65 /// Return the current position and prepare to use it as the start
66 /// position of a section given the section type \p Type and its position
67 /// \p LayoutIdx in SectionHdrLayout.
70  uint32_t LayoutIdx) {
71  uint64_t SectionStart = OutputStream->tell();
72  assert(LayoutIdx < SectionHdrLayout.size() && "LayoutIdx out of range");
73  const auto &Entry = SectionHdrLayout[LayoutIdx];
74  assert(Entry.Type == Type && "Unexpected section type");
75  // Use LocalBuf as a temporary output for writting data.
77  LocalBufStream.swap(OutputStream);
78  return SectionStart;
79 }
80 
81 std::error_code SampleProfileWriterExtBinaryBase::compressAndOutput() {
84  std::string &UncompressedStrings =
85  static_cast<raw_string_ostream *>(LocalBufStream.get())->str();
86  if (UncompressedStrings.size() == 0)
88  auto &OS = *OutputStream;
89  SmallString<128> CompressedStrings;
90  llvm::Error E = zlib::compress(UncompressedStrings, CompressedStrings,
92  if (E)
94  encodeULEB128(UncompressedStrings.size(), OS);
95  encodeULEB128(CompressedStrings.size(), OS);
96  OS << CompressedStrings.str();
97  UncompressedStrings.clear();
99 }
100 
101 /// Add a new section into section header table given the section type
102 /// \p Type, its position \p LayoutIdx in SectionHdrLayout and the
103 /// location \p SectionStart where the section should be written to.
105  SecType Type, uint32_t LayoutIdx, uint64_t SectionStart) {
106  assert(LayoutIdx < SectionHdrLayout.size() && "LayoutIdx out of range");
107  const auto &Entry = SectionHdrLayout[LayoutIdx];
108  assert(Entry.Type == Type && "Unexpected section type");
110  LocalBufStream.swap(OutputStream);
111  if (std::error_code EC = compressAndOutput())
112  return EC;
113  }
114  SecHdrTable.push_back({Type, Entry.Flags, SectionStart - FileStart,
115  OutputStream->tell() - SectionStart, LayoutIdx});
117 }
118 
119 std::error_code
121  if (std::error_code EC = writeHeader(ProfileMap))
122  return EC;
123 
124  std::string LocalBuf;
125  LocalBufStream = std::make_unique<raw_string_ostream>(LocalBuf);
126  if (std::error_code EC = writeSections(ProfileMap))
127  return EC;
128 
129  if (std::error_code EC = writeSecHdrTable())
130  return EC;
131 
133 }
134 
136  const SampleContext &Context) {
137  if (Context.hasContext())
138  return writeCSNameIdx(Context);
139  else
141 }
142 
143 std::error_code
145  const auto &Ret = CSNameTable.find(Context);
146  if (Ret == CSNameTable.end())
148  encodeULEB128(Ret->second, *OutputStream);
150 }
151 
152 std::error_code
154  uint64_t Offset = OutputStream->tell();
155  auto &Context = S.getContext();
156  FuncOffsetTable[Context] = Offset - SecLBRProfileStart;
157  encodeULEB128(S.getHeadSamples(), *OutputStream);
158  return writeBody(S);
159 }
160 
162  auto &OS = *OutputStream;
163 
164  // Write out the table size.
165  encodeULEB128(FuncOffsetTable.size(), OS);
166 
167  // Write out FuncOffsetTable.
168  auto WriteItem = [&](const SampleContext &Context, uint64_t Offset) {
169  if (std::error_code EC = writeContextIdx(Context))
170  return EC;
171  encodeULEB128(Offset, OS);
172  return (std::error_code)sampleprof_error::success;
173  };
174 
176  // Sort the contexts before writing them out. This is to help fast load all
177  // context profiles for a function as well as their callee contexts which
178  // can help profile-guided importing for ThinLTO.
179  std::map<SampleContext, uint64_t> OrderedFuncOffsetTable(
180  FuncOffsetTable.begin(), FuncOffsetTable.end());
181  for (const auto &Entry : OrderedFuncOffsetTable) {
182  if (std::error_code EC = WriteItem(Entry.first, Entry.second))
183  return EC;
184  }
186  } else {
187  for (const auto &Entry : FuncOffsetTable) {
188  if (std::error_code EC = WriteItem(Entry.first, Entry.second))
189  return EC;
190  }
191  }
192 
193  FuncOffsetTable.clear();
195 }
196 
198  const SampleProfileMap &Profiles) {
201  auto &OS = *OutputStream;
202  for (const auto &Entry : Profiles) {
203  if (std::error_code EC = writeContextIdx(Entry.second.getContext()))
204  return EC;
206  encodeULEB128(Entry.second.getFunctionHash(), OS);
208  encodeULEB128(Entry.second.getContext().getAllAttributes(), OS);
209  }
211 }
212 
214  if (!UseMD5)
216 
217  auto &OS = *OutputStream;
218  std::set<StringRef> V;
220 
221  // Write out the MD5 name table. We wrote unencoded MD5 so reader can
222  // retrieve the name using the name index without having to read the
223  // whole name table.
224  encodeULEB128(NameTable.size(), OS);
226  for (auto N : V)
227  Writer.write(MD5Hash(N));
229 }
230 
232  const SampleProfileMap &ProfileMap) {
233  for (const auto &I : ProfileMap) {
234  assert(I.first == I.second.getContext() && "Inconsistent profile map");
235  addContext(I.second.getContext());
236  addNames(I.second);
237  }
238 
239  // If NameTable contains ".__uniq." suffix, set SecFlagUniqSuffix flag
240  // so compiler won't strip the suffix during profile matching after
241  // seeing the flag in the profile.
242  for (const auto &I : NameTable) {
243  if (I.first.find(FunctionSamples::UniqSuffix) != StringRef::npos) {
245  break;
246  }
247  }
248 
249  if (auto EC = writeNameTable())
250  return EC;
252 }
253 
255  // Sort the names to make CSNameTable deterministic.
256  std::set<SampleContext> OrderedContexts;
257  for (const auto &I : CSNameTable)
258  OrderedContexts.insert(I.first);
259  assert(OrderedContexts.size() == CSNameTable.size() &&
260  "Unmatched ordered and unordered contexts");
261  uint64_t I = 0;
262  for (auto &Context : OrderedContexts)
263  CSNameTable[Context] = I++;
264 
265  auto &OS = *OutputStream;
266  encodeULEB128(OrderedContexts.size(), OS);
268  for (auto Context : OrderedContexts) {
269  auto Frames = Context.getContextFrames();
270  encodeULEB128(Frames.size(), OS);
271  for (auto &Callsite : Frames) {
272  if (std::error_code EC = writeNameIdx(Callsite.CallerName))
273  return EC;
274  encodeULEB128(Callsite.Callsite.LineOffset, OS);
275  encodeULEB128(Callsite.Callsite.Discriminator, OS);
276  }
277  }
278 
280 }
281 
282 std::error_code
284  if (ProfSymList && ProfSymList->size() > 0)
285  if (std::error_code EC = ProfSymList->write(*OutputStream))
286  return EC;
287 
289 }
290 
292  SecType Type, uint32_t LayoutIdx, const SampleProfileMap &ProfileMap) {
293  // The setting of SecFlagCompress should happen before markSectionStart.
294  if (Type == SecProfileSymbolList && ProfSymList && ProfSymList->toCompress())
304 
305  uint64_t SectionStart = markSectionStart(Type, LayoutIdx);
306  switch (Type) {
307  case SecProfSummary:
308  computeSummary(ProfileMap);
309  if (auto EC = writeSummary())
310  return EC;
311  break;
312  case SecNameTable:
313  if (auto EC = writeNameTableSection(ProfileMap))
314  return EC;
315  break;
316  case SecCSNameTable:
317  if (auto EC = writeCSNameTableSection())
318  return EC;
319  break;
320  case SecLBRProfile:
322  if (std::error_code EC = writeFuncProfiles(ProfileMap))
323  return EC;
324  break;
325  case SecFuncOffsetTable:
326  if (auto EC = writeFuncOffsetTable())
327  return EC;
328  break;
329  case SecFuncMetadata:
330  if (std::error_code EC = writeFuncMetadata(ProfileMap))
331  return EC;
332  break;
334  if (auto EC = writeProfileSymbolListSection())
335  return EC;
336  break;
337  default:
338  if (auto EC = writeCustomSection(Type))
339  return EC;
340  break;
341  }
342  if (std::error_code EC = addNewSection(Type, LayoutIdx, SectionStart))
343  return EC;
345 }
346 
347 std::error_code SampleProfileWriterExtBinary::writeDefaultLayout(
348  const SampleProfileMap &ProfileMap) {
349  // The const indices passed to writeOneSection below are specifying the
350  // positions of the sections in SectionHdrLayout. Look at
351  // initSectionHdrLayout to find out where each section is located in
352  // SectionHdrLayout.
353  if (auto EC = writeOneSection(SecProfSummary, 0, ProfileMap))
354  return EC;
355  if (auto EC = writeOneSection(SecNameTable, 1, ProfileMap))
356  return EC;
357  if (auto EC = writeOneSection(SecCSNameTable, 2, ProfileMap))
358  return EC;
359  if (auto EC = writeOneSection(SecLBRProfile, 4, ProfileMap))
360  return EC;
361  if (auto EC = writeOneSection(SecProfileSymbolList, 5, ProfileMap))
362  return EC;
363  if (auto EC = writeOneSection(SecFuncOffsetTable, 3, ProfileMap))
364  return EC;
365  if (auto EC = writeOneSection(SecFuncMetadata, 6, ProfileMap))
366  return EC;
368 }
369 
370 static void splitProfileMapToTwo(const SampleProfileMap &ProfileMap,
371  SampleProfileMap &ContextProfileMap,
372  SampleProfileMap &NoContextProfileMap) {
373  for (const auto &I : ProfileMap) {
374  if (I.second.getCallsiteSamples().size())
375  ContextProfileMap.insert({I.first, I.second});
376  else
377  NoContextProfileMap.insert({I.first, I.second});
378  }
379 }
380 
381 std::error_code SampleProfileWriterExtBinary::writeCtxSplitLayout(
382  const SampleProfileMap &ProfileMap) {
383  SampleProfileMap ContextProfileMap, NoContextProfileMap;
384  splitProfileMapToTwo(ProfileMap, ContextProfileMap, NoContextProfileMap);
385 
386  if (auto EC = writeOneSection(SecProfSummary, 0, ProfileMap))
387  return EC;
388  if (auto EC = writeOneSection(SecNameTable, 1, ProfileMap))
389  return EC;
390  if (auto EC = writeOneSection(SecLBRProfile, 3, ContextProfileMap))
391  return EC;
392  if (auto EC = writeOneSection(SecFuncOffsetTable, 2, ContextProfileMap))
393  return EC;
394  // Mark the section to have no context. Note section flag needs to be set
395  // before writing the section.
397  if (auto EC = writeOneSection(SecLBRProfile, 5, NoContextProfileMap))
398  return EC;
399  // Mark the section to have no context. Note section flag needs to be set
400  // before writing the section.
402  if (auto EC = writeOneSection(SecFuncOffsetTable, 4, NoContextProfileMap))
403  return EC;
404  if (auto EC = writeOneSection(SecProfileSymbolList, 6, ProfileMap))
405  return EC;
406  if (auto EC = writeOneSection(SecFuncMetadata, 7, ProfileMap))
407  return EC;
408 
410 }
411 
412 std::error_code SampleProfileWriterExtBinary::writeSections(
413  const SampleProfileMap &ProfileMap) {
414  std::error_code EC;
415  if (SecLayout == DefaultLayout)
416  EC = writeDefaultLayout(ProfileMap);
417  else if (SecLayout == CtxSplitLayout)
418  EC = writeCtxSplitLayout(ProfileMap);
419  else
420  llvm_unreachable("Unsupported layout");
421  return EC;
422 }
423 
424 std::error_code
426  if (std::error_code EC = SampleProfileWriter::write(ProfileMap))
427  return EC;
428  if (std::error_code EC = writeFuncOffsetTable())
429  return EC;
431 }
432 
433 /// Write samples to a text file.
434 ///
435 /// Note: it may be tempting to implement this in terms of
436 /// FunctionSamples::print(). Please don't. The dump functionality is intended
437 /// for debugging and has no specified form.
438 ///
439 /// The format used here is more structured and deliberate because
440 /// it needs to be parsed by the SampleProfileReaderText class.
442  auto &OS = *OutputStream;
444  OS << "[" << S.getContext().toString() << "]:" << S.getTotalSamples();
445  else
446  OS << S.getName() << ":" << S.getTotalSamples();
447 
448  if (Indent == 0)
449  OS << ":" << S.getHeadSamples();
450  OS << "\n";
451 
452  SampleSorter<LineLocation, SampleRecord> SortedSamples(S.getBodySamples());
453  for (const auto &I : SortedSamples.get()) {
454  LineLocation Loc = I->first;
455  const SampleRecord &Sample = I->second;
456  OS.indent(Indent + 1);
457  if (Loc.Discriminator == 0)
458  OS << Loc.LineOffset << ": ";
459  else
460  OS << Loc.LineOffset << "." << Loc.Discriminator << ": ";
461 
462  OS << Sample.getSamples();
463 
464  for (const auto &J : Sample.getSortedCallTargets())
465  OS << " " << J.first << ":" << J.second;
466  OS << "\n";
467  }
468 
470  S.getCallsiteSamples());
471  Indent += 1;
472  for (const auto &I : SortedCallsiteSamples.get())
473  for (const auto &FS : I->second) {
474  LineLocation Loc = I->first;
475  const FunctionSamples &CalleeSamples = FS.second;
476  OS.indent(Indent);
477  if (Loc.Discriminator == 0)
478  OS << Loc.LineOffset << ": ";
479  else
480  OS << Loc.LineOffset << "." << Loc.Discriminator << ": ";
481  if (std::error_code EC = writeSample(CalleeSamples))
482  return EC;
483  }
484  Indent -= 1;
485 
486  if (Indent == 0) {
488  OS.indent(Indent + 1);
489  OS << "!CFGChecksum: " << S.getFunctionHash() << "\n";
490  }
492  OS.indent(Indent + 1);
493  OS << "!Attributes: " << S.getContext().getAllAttributes() << "\n";
494  }
495  }
496 
498 }
499 
500 std::error_code
502  assert(!Context.hasContext() && "cs profile is not supported");
503  return writeNameIdx(Context.getName());
504 }
505 
507  auto &NTable = getNameTable();
508  const auto &Ret = NTable.find(FName);
509  if (Ret == NTable.end())
511  encodeULEB128(Ret->second, *OutputStream);
513 }
514 
516  auto &NTable = getNameTable();
517  NTable.insert(std::make_pair(FName, 0));
518 }
519 
521  addName(Context.getName());
522 }
523 
525  // Add all the names in indirect call targets.
526  for (const auto &I : S.getBodySamples()) {
527  const SampleRecord &Sample = I.second;
528  for (const auto &J : Sample.getCallTargets())
529  addName(J.first());
530  }
531 
532  // Recursively add all the names for inlined callsites.
533  for (const auto &J : S.getCallsiteSamples())
534  for (const auto &FS : J.second) {
535  const FunctionSamples &CalleeSamples = FS.second;
536  addName(CalleeSamples.getName());
537  addNames(CalleeSamples);
538  }
539 }
540 
542  const SampleContext &Context) {
543  if (Context.hasContext()) {
544  for (auto &Callsite : Context.getContextFrames())
545  SampleProfileWriterBinary::addName(Callsite.CallerName);
546  CSNameTable.insert(std::make_pair(Context, 0));
547  } else {
549  }
550 }
551 
553  MapVector<StringRef, uint32_t> &NameTable, std::set<StringRef> &V) {
554  // Sort the names to make NameTable deterministic.
555  for (const auto &I : NameTable)
556  V.insert(I.first);
557  int i = 0;
558  for (const StringRef &N : V)
559  NameTable[N] = i++;
560 }
561 
563  auto &OS = *OutputStream;
564  std::set<StringRef> V;
566 
567  // Write out the name table.
568  encodeULEB128(NameTable.size(), OS);
569  for (auto N : V) {
570  OS << N;
571  encodeULEB128(0, OS);
572  }
574 }
575 
577  auto &OS = *OutputStream;
578 
579  // Fill the slot remembered by TableOffset with the offset of FuncOffsetTable.
580  auto &OFS = static_cast<raw_fd_ostream &>(OS);
581  uint64_t FuncOffsetTableStart = OS.tell();
582  if (OFS.seek(TableOffset) == (uint64_t)-1)
585  Writer.write(FuncOffsetTableStart);
586  if (OFS.seek(FuncOffsetTableStart) == (uint64_t)-1)
588 
589  // Write out the table size.
590  encodeULEB128(FuncOffsetTable.size(), OS);
591 
592  // Write out FuncOffsetTable.
593  for (auto Entry : FuncOffsetTable) {
594  if (std::error_code EC = writeNameIdx(Entry.first))
595  return EC;
596  encodeULEB128(Entry.second, OS);
597  }
599 }
600 
602  auto &OS = *OutputStream;
603  std::set<StringRef> V;
605 
606  // Write out the name table.
607  encodeULEB128(NameTable.size(), OS);
608  for (auto N : V) {
609  encodeULEB128(MD5Hash(N), OS);
610  }
612 }
613 
614 std::error_code
616  auto &OS = *OutputStream;
617  // Write file magic identifier.
619  encodeULEB128(SPVersion(), OS);
621 }
622 
623 std::error_code
626 
627  computeSummary(ProfileMap);
628  if (auto EC = writeSummary())
629  return EC;
630 
631  // Generate the name table for all the functions referenced in the profile.
632  for (const auto &I : ProfileMap) {
633  assert(I.first == I.second.getContext() && "Inconsistent profile map");
634  addContext(I.first);
635  addNames(I.second);
636  }
637 
638  writeNameTable();
640 }
641 
643  for (auto &Entry : SectionHdrLayout)
645 }
646 
649 }
650 
651 void SampleProfileWriterExtBinaryBase::allocSecHdrTable() {
653 
654  Writer.write(static_cast<uint64_t>(SectionHdrLayout.size()));
655  SecHdrTableOffset = OutputStream->tell();
656  for (uint32_t i = 0; i < SectionHdrLayout.size(); i++) {
657  Writer.write(static_cast<uint64_t>(-1));
658  Writer.write(static_cast<uint64_t>(-1));
659  Writer.write(static_cast<uint64_t>(-1));
660  Writer.write(static_cast<uint64_t>(-1));
661  }
662 }
663 
664 std::error_code SampleProfileWriterExtBinaryBase::writeSecHdrTable() {
665  auto &OFS = static_cast<raw_fd_ostream &>(*OutputStream);
666  uint64_t Saved = OutputStream->tell();
667 
668  // Set OutputStream to the location saved in SecHdrTableOffset.
669  if (OFS.seek(SecHdrTableOffset) == (uint64_t)-1)
672 
673  assert(SecHdrTable.size() == SectionHdrLayout.size() &&
674  "SecHdrTable entries doesn't match SectionHdrLayout");
675  SmallVector<uint32_t, 16> IndexMap(SecHdrTable.size(), -1);
676  for (uint32_t TableIdx = 0; TableIdx < SecHdrTable.size(); TableIdx++) {
677  IndexMap[SecHdrTable[TableIdx].LayoutIndex] = TableIdx;
678  }
679 
680  // Write the section header table in the order specified in
681  // SectionHdrLayout. SectionHdrLayout specifies the sections
682  // order in which profile reader expect to read, so the section
683  // header table should be written in the order in SectionHdrLayout.
684  // Note that the section order in SecHdrTable may be different
685  // from the order in SectionHdrLayout, for example, SecFuncOffsetTable
686  // needs to be computed after SecLBRProfile (the order in SecHdrTable),
687  // but it needs to be read before SecLBRProfile (the order in
688  // SectionHdrLayout). So we use IndexMap above to switch the order.
689  for (uint32_t LayoutIdx = 0; LayoutIdx < SectionHdrLayout.size();
690  LayoutIdx++) {
691  assert(IndexMap[LayoutIdx] < SecHdrTable.size() &&
692  "Incorrect LayoutIdx in SecHdrTable");
693  auto Entry = SecHdrTable[IndexMap[LayoutIdx]];
694  Writer.write(static_cast<uint64_t>(Entry.Type));
695  Writer.write(static_cast<uint64_t>(Entry.Flags));
696  Writer.write(static_cast<uint64_t>(Entry.Offset));
697  Writer.write(static_cast<uint64_t>(Entry.Size));
698  }
699 
700  // Reset OutputStream.
701  if (OFS.seek(Saved) == (uint64_t)-1)
703 
705 }
706 
707 std::error_code SampleProfileWriterExtBinaryBase::writeHeader(
708  const SampleProfileMap &ProfileMap) {
709  auto &OS = *OutputStream;
710  FileStart = OS.tell();
712 
713  allocSecHdrTable();
715 }
716 
718  const SampleProfileMap &ProfileMap) {
720  if (auto EC = SampleProfileWriterBinary::writeHeader(ProfileMap))
721  return EC;
722 
723  // Reserve a slot for the offset of function offset table. The slot will
724  // be populated with the offset of FuncOffsetTable later.
725  TableOffset = OutputStream->tell();
726  Writer.write(static_cast<uint64_t>(-2));
728 }
729 
731  auto &OS = *OutputStream;
732  encodeULEB128(Summary->getTotalCount(), OS);
733  encodeULEB128(Summary->getMaxCount(), OS);
734  encodeULEB128(Summary->getMaxFunctionCount(), OS);
735  encodeULEB128(Summary->getNumCounts(), OS);
736  encodeULEB128(Summary->getNumFunctions(), OS);
737  std::vector<ProfileSummaryEntry> &Entries = Summary->getDetailedSummary();
738  encodeULEB128(Entries.size(), OS);
739  for (auto Entry : Entries) {
740  encodeULEB128(Entry.Cutoff, OS);
741  encodeULEB128(Entry.MinCount, OS);
742  encodeULEB128(Entry.NumCounts, OS);
743  }
745 }
747  auto &OS = *OutputStream;
748  if (std::error_code EC = writeContextIdx(S.getContext()))
749  return EC;
750 
751  encodeULEB128(S.getTotalSamples(), OS);
752 
753  // Emit all the body samples.
754  encodeULEB128(S.getBodySamples().size(), OS);
755  for (const auto &I : S.getBodySamples()) {
756  LineLocation Loc = I.first;
757  const SampleRecord &Sample = I.second;
758  encodeULEB128(Loc.LineOffset, OS);
759  encodeULEB128(Loc.Discriminator, OS);
760  encodeULEB128(Sample.getSamples(), OS);
761  encodeULEB128(Sample.getCallTargets().size(), OS);
762  for (const auto &J : Sample.getSortedCallTargets()) {
763  StringRef Callee = J.first;
764  uint64_t CalleeSamples = J.second;
765  if (std::error_code EC = writeNameIdx(Callee))
766  return EC;
767  encodeULEB128(CalleeSamples, OS);
768  }
769  }
770 
771  // Recursively emit all the callsite samples.
772  uint64_t NumCallsites = 0;
773  for (const auto &J : S.getCallsiteSamples())
774  NumCallsites += J.second.size();
775  encodeULEB128(NumCallsites, OS);
776  for (const auto &J : S.getCallsiteSamples())
777  for (const auto &FS : J.second) {
778  LineLocation Loc = J.first;
779  const FunctionSamples &CalleeSamples = FS.second;
780  encodeULEB128(Loc.LineOffset, OS);
781  encodeULEB128(Loc.Discriminator, OS);
782  if (std::error_code EC = writeBody(CalleeSamples))
783  return EC;
784  }
785 
787 }
788 
789 /// Write samples of a top-level function to a binary file.
790 ///
791 /// \returns true if the samples were written successfully, false otherwise.
792 std::error_code
794  encodeULEB128(S.getHeadSamples(), *OutputStream);
795  return writeBody(S);
796 }
797 
798 std::error_code
800  uint64_t Offset = OutputStream->tell();
801  StringRef Name = S.getName();
803  encodeULEB128(S.getHeadSamples(), *OutputStream);
804  return writeBody(S);
805 }
806 
807 /// Create a sample profile file writer based on the specified format.
808 ///
809 /// \param Filename The file to create.
810 ///
811 /// \param Format Encoding format for the profile file.
812 ///
813 /// \returns an error code indicating the status of the created writer.
816  std::error_code EC;
817  std::unique_ptr<raw_ostream> OS;
818  if (Format == SPF_Binary || Format == SPF_Ext_Binary ||
820  OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_None));
821  else
822  OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_TextWithCRLF));
823  if (EC)
824  return EC;
825 
826  return create(OS, Format);
827 }
828 
829 /// Create a sample profile stream writer based on the specified format.
830 ///
831 /// \param OS The output stream to store the profile data to.
832 ///
833 /// \param Format Encoding format for the profile file.
834 ///
835 /// \returns an error code indicating the status of the created writer.
837 SampleProfileWriter::create(std::unique_ptr<raw_ostream> &OS,
838  SampleProfileFormat Format) {
839  std::error_code EC;
840  std::unique_ptr<SampleProfileWriter> Writer;
841 
842  // Currently only Text and Extended Binary format are supported for CSSPGO.
846 
847  if (Format == SPF_Binary)
848  Writer.reset(new SampleProfileWriterRawBinary(OS));
849  else if (Format == SPF_Ext_Binary)
850  Writer.reset(new SampleProfileWriterExtBinary(OS));
851  else if (Format == SPF_Compact_Binary)
852  Writer.reset(new SampleProfileWriterCompactBinary(OS));
853  else if (Format == SPF_Text)
854  Writer.reset(new SampleProfileWriterText(OS));
855  else if (Format == SPF_GCC)
857  else
859 
860  if (EC)
861  return EC;
862 
863  Writer->Format = Format;
864  return std::move(Writer);
865 }
866 
869  Summary = Builder.computeSummaryForProfiles(ProfileMap);
870 }
i
i
Definition: README.txt:29
llvm::sampleprof::SampleProfileWriter::OutputStream
std::unique_ptr< raw_ostream > OutputStream
Output stream where to emit the profile to.
Definition: SampleProfWriter.h:87
llvm::sampleprof::SampleRecord::getSamples
uint64_t getSamples() const
Definition: SampleProf.h:361
llvm::sampleprof::SampleProfileWriterBinary::NameTable
MapVector< StringRef, uint32_t > NameTable
Definition: SampleProfWriter.h:144
Compression.h
llvm::sampleprof::SampleProfileWriterText
Sample-based profile writer (text format).
Definition: SampleProfWriter.h:100
llvm::sampleprof::SampleProfileWriter::create
static ErrorOr< std::unique_ptr< SampleProfileWriter > > create(StringRef Filename, SampleProfileFormat Format)
Profile writer factory.
Definition: SampleProfWriter.cpp:815
llvm::sampleprof::CtxSplitLayout
@ CtxSplitLayout
Definition: SampleProfWriter.h:38
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::sampleprof::SecFuncMetadataFlags::SecFlagHasAttribute
@ SecFlagHasAttribute
llvm::sampleprof::SampleProfileWriterBinary::stablizeNameTable
void stablizeNameTable(MapVector< StringRef, uint32_t > &NameTable, std::set< StringRef > &V)
Definition: SampleProfWriter.cpp:552
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeNameTable
virtual std::error_code writeNameTable() override
Definition: SampleProfWriter.cpp:213
llvm::sampleprof::SecProfSummaryFlags::SecFlagFSDiscriminator
@ SecFlagFSDiscriminator
SecFlagFSDiscriminator means this profile uses flow-sensitive discriminators.
llvm::sampleprof::SampleSorter::get
const SamplesWithLocList & get() const
Definition: SampleProf.h:1115
FileSystem.h
llvm::sys::fs::OF_None
@ OF_None
Definition: FileSystem.h:757
llvm::sampleprof::FunctionSamples::ProfileIsProbeBased
static bool ProfileIsProbeBased
Definition: SampleProf.h:1010
llvm::sampleprof::SampleProfileWriter::Format
SampleProfileFormat Format
Profile format.
Definition: SampleProfWriter.h:96
llvm::sampleprof::FunctionSamples::ProfileIsCS
static bool ProfileIsCS
Definition: SampleProf.h:1012
llvm::sampleprof::SampleProfileWriterBinary::writeBody
std::error_code writeBody(const FunctionSamples &S)
Definition: SampleProfWriter.cpp:746
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeFuncOffsetTable
std::error_code writeFuncOffsetTable()
Definition: SampleProfWriter.cpp:161
StringRef.h
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:60
llvm::SmallVector< uint32_t, 16 >
llvm::sampleprof::ProfileSymbolList::size
unsigned size()
Definition: SampleProf.h:1162
splitProfileMapToTwo
static void splitProfileMapToTwo(const SampleProfileMap &ProfileMap, SampleProfileMap &ContextProfileMap, SampleProfileMap &NoContextProfileMap)
Definition: SampleProfWriter.cpp:370
llvm::sampleprof::DefaultLayout
@ DefaultLayout
Definition: SampleProfWriter.h:34
llvm::sampleprof::SecProfSummaryFlags::SecFlagFullContext
@ SecFlagFullContext
SecFlagContext means this is context-sensitive profile for CSSPGO.
llvm::sampleprof::SampleProfileMap
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
Definition: SampleProf.h:1091
llvm::sampleprof::hasSecFlag
static bool hasSecFlag(const SecHdrTableEntry &Entry, SecFlagType Flag)
Definition: SampleProf.h:264
Saved
Fixup Statepoint Caller Saved
Definition: FixupStatepointCallerSaved.cpp:92
llvm::sampleprof::SPF_GCC
@ SPF_GCC
Definition: SampleProf.h:94
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::sampleprof::SampleProfileWriterBinary::addName
void addName(StringRef FName)
Definition: SampleProfWriter.cpp:515
llvm::sampleprof::SecFuncOffsetTable
@ SecFuncOffsetTable
Definition: SampleProf.h:126
llvm::sampleprof::SampleProfileWriter::computeSummary
void computeSummary(const SampleProfileMap &ProfileMap)
Compute summary for this profile.
Definition: SampleProfWriter.cpp:867
llvm::sampleprof::addSecFlag
static void addSecFlag(SecHdrTableEntry &Entry, SecFlagType Flag)
Definition: SampleProf.h:248
llvm::sampleprof::SecCommonFlags::SecFlagCompress
@ SecFlagCompress
llvm::sampleprof::SampleProfileWriterCompactBinary::writeFuncOffsetTable
std::error_code writeFuncOffsetTable()
Definition: SampleProfWriter.cpp:576
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::sampleprof::SampleProfileWriterCompactBinary::writeHeader
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap) override
Write a file header for the profile file.
Definition: SampleProfWriter.cpp:717
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeNameTableSection
std::error_code writeNameTableSection(const SampleProfileMap &ProfileMap)
Definition: SampleProfWriter.cpp:231
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::sampleprof::FunctionSamples::getName
StringRef getName() const
Return the function name.
Definition: SampleProf.h:915
llvm::sampleprof::SampleProfileWriter::writeFuncProfiles
virtual std::error_code writeFuncProfiles(const SampleProfileMap &ProfileMap)
Definition: SampleProfWriter.cpp:45
llvm::sampleprof::SampleProfileWriterExtBinaryBase::setToCompressAllSections
virtual void setToCompressAllSections() override
Definition: SampleProfWriter.cpp:642
llvm::support::endian::Writer
Adapter to write values to a stream in a particular byte order.
Definition: EndianStream.h:52
ProfileCommon.h
llvm::sampleprof::SampleProfileWriterBinary::writeSample
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
Definition: SampleProfWriter.cpp:793
llvm::SampleProfileSummaryBuilder
Definition: ProfileCommon.h:88
llvm::sampleprof::SPF_Binary
@ SPF_Binary
Definition: SampleProf.h:96
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeSample
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
Definition: SampleProfWriter.cpp:153
llvm::sampleprof::LineLocation::Discriminator
uint32_t Discriminator
Definition: SampleProf.h:300
llvm::sampleprof::LineLocation::LineOffset
uint32_t LineOffset
Definition: SampleProf.h:299
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCustomSection
virtual std::error_code writeCustomSection(SecType Type)=0
llvm::sampleprof::SampleProfileWriter::Summary
std::unique_ptr< ProfileSummary > Summary
Profile summary.
Definition: SampleProfWriter.h:90
llvm::sampleprof::SecFuncMetadataFlags::SecFlagIsProbeBased
@ SecFlagIsProbeBased
llvm::sampleprof_error::unsupported_writing_format
@ unsupported_writing_format
llvm::sampleprof::SampleProfileFormat
SampleProfileFormat
Definition: SampleProf.h:90
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeSections
virtual std::error_code writeSections(const SampleProfileMap &ProfileMap)=0
MD5.h
llvm::sampleprof::SampleProfileWriterBinary::addNames
void addNames(const FunctionSamples &S)
Definition: SampleProfWriter.cpp:524
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::zlib::BestSizeCompression
static constexpr int BestSizeCompression
Definition: Compression.h:28
llvm::support::little
@ little
Definition: Endian.h:27
llvm::sampleprof::SampleProfileWriter::write
virtual std::error_code write(const SampleProfileMap &ProfileMap)
Write all the sample profiles in the given map of samples.
Definition: SampleProfWriter.cpp:55
llvm::sampleprof::SampleProfileWriterRawBinary
Definition: SampleProfWriter.h:156
llvm::sampleprof::SampleProfileWriterBinary::writeHeader
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap) override
Write a file header for the profile file.
Definition: SampleProfWriter.cpp:624
llvm::sampleprof::SampleProfileWriterExtBinaryBase::addContext
virtual void addContext(const SampleContext &Context) override
Definition: SampleProfWriter.cpp:541
llvm::sampleprof::SampleProfileWriterBinary::writeNameTable
virtual std::error_code writeNameTable()
Definition: SampleProfWriter.cpp:562
SampleProf.h
llvm::sampleprof::SampleProfileWriter::writeSample
virtual std::error_code writeSample(const FunctionSamples &S)=0
Write sample profiles in S.
llvm::sampleprof::SPMagic
static uint64_t SPMagic(SampleProfileFormat Format=SPF_Binary)
Definition: SampleProf.h:99
llvm::zlib::compress
Error compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, int Level=DefaultCompression)
Definition: Compression.cpp:49
llvm::sampleprof::SampleProfileWriterExtBinaryBase::SectionHdrLayout
SmallVector< SecHdrTableEntry, 8 > SectionHdrLayout
Definition: SampleProfWriter.h:283
llvm::sampleprof::SampleProfileWriterCompactBinary::TableOffset
uint64_t TableOffset
The offset of the slot to be filled with the offset of FuncOffsetTable towards profile start.
Definition: SampleProfWriter.h:396
llvm::sampleprof::SampleProfileWriterExtBinaryBase::write
virtual std::error_code write(const SampleProfileMap &ProfileMap) override
Write all the sample profiles in the given map of samples.
Definition: SampleProfWriter.cpp:120
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::SmallString< 128 >
llvm::sys::fs::OF_TextWithCRLF
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
Definition: FileSystem.h:770
llvm::sampleprof::SampleProfileWriterCompactBinary::writeNameTable
virtual std::error_code writeNameTable() override
Definition: SampleProfWriter.cpp:601
llvm::sampleprof::SampleRecord::getCallTargets
const CallTargetMap & getCallTargets() const
Definition: SampleProf.h:362
llvm::sampleprof::SampleProfileWriterCompactBinary::FuncOffsetTable
MapVector< StringRef, uint64_t > FuncOffsetTable
The table mapping from function name to the offset of its FunctionSample towards profile start.
Definition: SampleProfWriter.h:393
llvm::sampleprof::SampleProfileWriterExtBinaryBase::markSectionStart
uint64_t markSectionStart(SecType Type, uint32_t LayoutIdx)
Return the current position and prepare to use it as the start position of a section given the sectio...
Definition: SampleProfWriter.cpp:69
llvm::sampleprof::SPF_Compact_Binary
@ SPF_Compact_Binary
Definition: SampleProf.h:93
llvm::sampleprof::SecProfSummary
@ SecProfSummary
Definition: SampleProf.h:123
llvm::sampleprof::SampleProfileWriterBinary::getNameTable
virtual MapVector< StringRef, uint32_t > & getNameTable()
Definition: SampleProfWriter.h:132
uint64_t
llvm::sampleprof::SampleProfileWriterCompactBinary::write
virtual std::error_code write(const SampleProfileMap &ProfileMap) override
Write all the sample profiles in the given map of samples.
Definition: SampleProfWriter.cpp:425
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:684
LEB128.h
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::sampleprof::SPF_Ext_Binary
@ SPF_Ext_Binary
Definition: SampleProf.h:95
ErrorOr.h
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCSNameIdx
std::error_code writeCSNameIdx(const SampleContext &Context)
Definition: SampleProfWriter.cpp:144
llvm::sampleprof::SecLBRProfile
@ SecLBRProfile
Definition: SampleProf.h:131
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::sampleprof::SampleRecord::getSortedCallTargets
const SortedCallTargetSet getSortedCallTargets() const
Definition: SampleProf.h:363
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::sampleprof::SampleProfileWriterBinary::addContext
virtual void addContext(const SampleContext &Context)
Definition: SampleProfWriter.cpp:520
llvm::sampleprof::SampleProfileWriterExtBinaryBase::addSectionFlag
void addSectionFlag(SecType Type, SecFlagType Flag)
Definition: SampleProfWriter.h:238
llvm::codeview::CompileSym2Flags::EC
@ EC
llvm::sampleprof::SampleProfileWriterText::writeSample
std::error_code writeSample(const FunctionSamples &S) override
Write samples to a text file.
Definition: SampleProfWriter.cpp:441
llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx
std::error_code writeNameIdx(StringRef FName)
Definition: SampleProfWriter.cpp:506
llvm::zlib::isAvailable
bool isAvailable()
Definition: Compression.cpp:47
llvm::StringMapImpl::size
unsigned size() const
Definition: StringMap.h:93
llvm::sampleprof::LineLocation
Represents the relative location of an instruction.
Definition: SampleProf.h:280
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::sampleprof::SampleProfileWriterExtBinaryBase::addNewSection
std::error_code addNewSection(SecType Sec, uint32_t LayoutIdx, uint64_t SectionStart)
Add a new section into section header table given the section type Type, its position LayoutIdx in Se...
Definition: SampleProfWriter.cpp:104
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::support::endian::Writer::write
void write(ArrayRef< value_type > Val)
Definition: EndianStream.h:56
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
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeFuncMetadata
std::error_code writeFuncMetadata(const SampleProfileMap &Profiles)
Definition: SampleProfWriter.cpp:197
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::SPF_Text
@ SPF_Text
Definition: SampleProf.h:92
llvm::sampleprof::SecFuncOffsetFlags::SecFlagOrdered
@ SecFlagOrdered
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:443
llvm::sampleprof::ProfileSymbolList::toCompress
bool toCompress()
Definition: SampleProf.h:1165
llvm::sampleprof::SampleProfileWriter::writeHeader
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap)=0
Write a file header for the profile file.
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:206
llvm::sampleprof_error::ostream_seek_unsupported
@ ostream_seek_unsupported
llvm::sampleprof::SampleProfileWriterExtBinary
Definition: SampleProfWriter.h:331
StringSet.h
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeOneSection
virtual std::error_code writeOneSection(SecType Type, uint32_t LayoutIdx, const SampleProfileMap &ProfileMap)
Definition: SampleProfWriter.cpp:291
llvm::sampleprof::ProfileSymbolList::write
std::error_code write(raw_ostream &OS)
Definition: SampleProf.cpp:422
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
EndianStream.h
llvm::sampleprof::SPVersion
static uint64_t SPVersion()
Definition: SampleProf.h:116
llvm::sampleprof::SampleProfileWriterBinary::writeSummary
std::error_code writeSummary()
Definition: SampleProfWriter.cpp:730
llvm::sampleprof::SampleProfileWriterExtBinaryBase::setToCompressSection
void setToCompressSection(SecType Type)
Definition: SampleProfWriter.cpp:647
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::sampleprof::SecProfileSymbolList
@ SecProfileSymbolList
Definition: SampleProf.h:125
llvm::sampleprof::SampleProfileWriterExtBinaryBase::SecLBRProfileStart
uint64_t SecLBRProfileStart
Definition: SampleProfWriter.h:289
llvm::sampleprof::SecType
SecType
Definition: SampleProf.h:121
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCSNameTableSection
std::error_code writeCSNameTableSection()
Definition: SampleProfWriter.cpp:254
llvm::sampleprof::SampleRecord
Representation of a single sample record.
Definition: SampleProf.h:315
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeProfileSymbolListSection
std::error_code writeProfileSymbolListSection()
Definition: SampleProfWriter.cpp:283
llvm::sampleprof_error::compress_failed
@ compress_failed
llvm::sampleprof::SampleProfileWriterBinary::writeContextIdx
virtual std::error_code writeContextIdx(const SampleContext &Context)
Definition: SampleProfWriter.cpp:501
llvm::sampleprof_error::zlib_unavailable
@ zlib_unavailable
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:259
llvm::sampleprof_error::success
@ success
llvm::sampleprof::SecNameTableFlags::SecFlagUniqSuffix
@ SecFlagUniqSuffix
llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeContextIdx
virtual std::error_code writeContextIdx(const SampleContext &Context) override
Definition: SampleProfWriter.cpp:135
llvm::sampleprof::SampleProfileWriterCompactBinary::writeSample
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
Definition: SampleProfWriter.cpp:799
llvm::sampleprof::SecCommonFlags::SecFlagFlat
@ SecFlagFlat
llvm::sampleprof::FunctionSamples::UniqSuffix
static constexpr const char * UniqSuffix
Definition: SampleProf.h:936
SampleProfWriter.h
N
#define N
llvm::sampleprof::SecCSNameTable
@ SecCSNameTable
Definition: SampleProf.h:128
llvm::ErrorOr
Represents either an error or a value T.
Definition: ErrorOr.h:56
llvm::encodeULEB128
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:80
llvm::sampleprof::SecNameTable
@ SecNameTable
Definition: SampleProf.h:124
llvm::sampleprof::SampleProfileWriterBinary::writeMagicIdent
virtual std::error_code writeMagicIdent(SampleProfileFormat Format)
Definition: SampleProfWriter.cpp:615
llvm::sampleprof::SecFuncMetadata
@ SecFuncMetadata
Definition: SampleProf.h:127
llvm::sampleprof_error::truncated_name_table
@ truncated_name_table
raw_ostream.h
Endian.h
llvm::sampleprof::SampleProfileWriterCompactBinary
Definition: SampleProfWriter.h:383
llvm::ProfileSummaryBuilder::DefaultCutoffs
static const ArrayRef< uint32_t > DefaultCutoffs
A vector of useful cutoff values for detailed summary.
Definition: ProfileCommon.h:65
llvm::sampleprof::SampleProfileWriterExtBinaryBase::SecLayout
SectionLayout SecLayout
Definition: SampleProfWriter.h:278
llvm::MD5Hash
uint64_t MD5Hash(StringRef Str)
Helper to compute and return lower 64 bits of the given string's MD5 hash.
Definition: MD5.h:122