LLVM  14.0.0git
InstrProf.h
Go to the documentation of this file.
1 //===- InstrProf.h - Instrumented profiling format support ------*- C++ -*-===//
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 // Instrumentation-based profiling data is generated by instrumented
10 // binaries through library functions in compiler-rt, and read by the clang
11 // frontend to feed PGO.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_PROFILEDATA_INSTRPROF_H
16 #define LLVM_PROFILEDATA_INSTRPROF_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/StringSet.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/IR/GlobalValue.h"
24 #include "llvm/IR/ProfileSummary.h"
27 #include "llvm/Support/Compiler.h"
28 #include "llvm/Support/Endian.h"
29 #include "llvm/Support/Error.h"
31 #include "llvm/Support/Host.h"
32 #include "llvm/Support/MD5.h"
35 #include <algorithm>
36 #include <cassert>
37 #include <cstddef>
38 #include <cstdint>
39 #include <cstring>
40 #include <list>
41 #include <memory>
42 #include <string>
43 #include <system_error>
44 #include <utility>
45 #include <vector>
46 
47 namespace llvm {
48 
49 class Function;
50 class GlobalVariable;
51 struct InstrProfRecord;
52 class InstrProfSymtab;
53 class Instruction;
54 class MDNode;
55 class Module;
56 
58 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) Kind,
60 };
61 
62 /// Return the name of the profile section corresponding to \p IPSK.
63 ///
64 /// The name of the section depends on the object format type \p OF. If
65 /// \p AddSegmentInfo is true, a segment prefix and additional linker hints may
66 /// be added to the section name (this is the default).
69  bool AddSegmentInfo = true);
70 
71 /// Return the name profile runtime entry point to do value profiling
72 /// for a given site.
74  return INSTR_PROF_VALUE_PROF_FUNC_STR;
75 }
76 
77 /// Return the name profile runtime entry point to do memop size value
78 /// profiling.
80  return INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR;
81 }
82 
83 /// Return the name prefix of variables containing instrumented function names.
84 inline StringRef getInstrProfNameVarPrefix() { return "__profn_"; }
85 
86 /// Return the name prefix of variables containing per-function control data.
87 inline StringRef getInstrProfDataVarPrefix() { return "__profd_"; }
88 
89 /// Return the name prefix of profile counter variables.
90 inline StringRef getInstrProfCountersVarPrefix() { return "__profc_"; }
91 
92 /// Return the name prefix of value profile variables.
93 inline StringRef getInstrProfValuesVarPrefix() { return "__profvp_"; }
94 
95 /// Return the name of value profile node array variables:
96 inline StringRef getInstrProfVNodesVarName() { return "__llvm_prf_vnodes"; }
97 
98 /// Return the name of the variable holding the strings (possibly compressed)
99 /// of all function's PGO names.
101  return "__llvm_prf_nm";
102 }
103 
104 /// Return the name of a covarage mapping variable (internal linkage)
105 /// for each instrumented source module. Such variables are allocated
106 /// in the __llvm_covmap section.
108  return "__llvm_coverage_mapping";
109 }
110 
111 /// Return the name of the internal variable recording the array
112 /// of PGO name vars referenced by the coverage mapping. The owning
113 /// functions of those names are not emitted by FE (e.g, unused inline
114 /// functions.)
116  return "__llvm_coverage_names";
117 }
118 
119 /// Return the name of function that registers all the per-function control
120 /// data at program startup time by calling __llvm_register_function. This
121 /// function has internal linkage and is called by __llvm_profile_init
122 /// runtime method. This function is not generated for these platforms:
123 /// Darwin, Linux, and FreeBSD.
125  return "__llvm_profile_register_functions";
126 }
127 
128 /// Return the name of the runtime interface that registers per-function control
129 /// data for one instrumented function.
131  return "__llvm_profile_register_function";
132 }
133 
134 /// Return the name of the runtime interface that registers the PGO name strings.
136  return "__llvm_profile_register_names_function";
137 }
138 
139 /// Return the name of the runtime initialization method that is generated by
140 /// the compiler. The function calls __llvm_profile_register_functions and
141 /// __llvm_profile_override_default_filename functions if needed. This function
142 /// has internal linkage and invoked at startup time via init_array.
143 inline StringRef getInstrProfInitFuncName() { return "__llvm_profile_init"; }
144 
145 /// Return the name of the hook variable defined in profile runtime library.
146 /// A reference to the variable causes the linker to link in the runtime
147 /// initialization module (which defines the hook variable).
149  return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_RUNTIME_VAR);
150 }
151 
152 /// Return the name of the compiler generated function that references the
153 /// runtime hook variable. The function is a weak global.
155  return "__llvm_profile_runtime_user";
156 }
157 
159  return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_COUNTER_BIAS_VAR);
160 }
161 
162 /// Return the marker used to separate PGO names during serialization.
163 inline StringRef getInstrProfNameSeparator() { return "\01"; }
164 
165 /// Return the modified name for function \c F suitable to be
166 /// used the key for profile lookup. Variable \c InLTO indicates if this
167 /// is called in LTO optimization passes.
168 std::string getPGOFuncName(const Function &F, bool InLTO = false,
169  uint64_t Version = INSTR_PROF_INDEX_VERSION);
170 
171 /// Return the modified name for a function suitable to be
172 /// used the key for profile lookup. The function's original
173 /// name is \c RawFuncName and has linkage of type \c Linkage.
174 /// The function is defined in module \c FileName.
175 std::string getPGOFuncName(StringRef RawFuncName,
177  StringRef FileName,
178  uint64_t Version = INSTR_PROF_INDEX_VERSION);
179 
180 /// Return the name of the global variable used to store a function
181 /// name in PGO instrumentation. \c FuncName is the name of the function
182 /// returned by the \c getPGOFuncName call.
183 std::string getPGOFuncNameVarName(StringRef FuncName,
185 
186 /// Create and return the global variable for function name used in PGO
187 /// instrumentation. \c FuncName is the name of the function returned
188 /// by \c getPGOFuncName call.
189 GlobalVariable *createPGOFuncNameVar(Function &F, StringRef PGOFuncName);
190 
191 /// Create and return the global variable for function name used in PGO
192 /// instrumentation. /// \c FuncName is the name of the function
193 /// returned by \c getPGOFuncName call, \c M is the owning module,
194 /// and \c Linkage is the linkage of the instrumented function.
195 GlobalVariable *createPGOFuncNameVar(Module &M,
197  StringRef PGOFuncName);
198 
199 /// Return the initializer in string of the PGO name var \c NameVar.
200 StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar);
201 
202 /// Given a PGO function name, remove the filename prefix and return
203 /// the original (static) function name.
204 StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName,
205  StringRef FileName = "<unknown>");
206 
207 /// Given a vector of strings (function PGO names) \c NameStrs, the
208 /// method generates a combined string \c Result that is ready to be
209 /// serialized. The \c Result string is comprised of three fields:
210 /// The first field is the length of the uncompressed strings, and the
211 /// the second field is the length of the zlib-compressed string.
212 /// Both fields are encoded in ULEB128. If \c doCompress is false, the
213 /// third field is the uncompressed strings; otherwise it is the
214 /// compressed string. When the string compression is off, the
215 /// second field will have value zero.
216 Error collectPGOFuncNameStrings(ArrayRef<std::string> NameStrs,
217  bool doCompression, std::string &Result);
218 
219 /// Produce \c Result string with the same format described above. The input
220 /// is vector of PGO function name variables that are referenced.
221 Error collectPGOFuncNameStrings(ArrayRef<GlobalVariable *> NameVars,
222  std::string &Result, bool doCompression = true);
223 
224 /// \c NameStrings is a string composed of one of more sub-strings encoded in
225 /// the format described above. The substrings are separated by 0 or more zero
226 /// bytes. This method decodes the string and populates the \c Symtab.
227 Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab);
228 
229 /// Check if INSTR_PROF_RAW_VERSION_VAR is defined. This global is only being
230 /// set in IR PGO compilation.
231 bool isIRPGOFlagSet(const Module *M);
232 
233 /// Check if we can safely rename this Comdat function. Instances of the same
234 /// comdat function may have different control flows thus can not share the
235 /// same counter variable.
236 bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken = false);
237 
239 #define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value,
241 };
242 
243 /// Get the value profile data for value site \p SiteIdx from \p InstrProfR
244 /// and annotate the instruction \p Inst with the value profile meta data.
245 /// Annotate up to \p MaxMDCount (default 3) number of records per value site.
246 void annotateValueSite(Module &M, Instruction &Inst,
247  const InstrProfRecord &InstrProfR,
249  uint32_t MaxMDCount = 3);
250 
251 /// Same as the above interface but using an ArrayRef, as well as \p Sum.
252 void annotateValueSite(Module &M, Instruction &Inst,
253  ArrayRef<InstrProfValueData> VDs, uint64_t Sum,
255 
256 /// Extract the value profile data from \p Inst which is annotated with
257 /// value profile meta data. Return false if there is no value data annotated,
258 /// otherwise return true.
259 bool getValueProfDataFromInst(const Instruction &Inst,
261  uint32_t MaxNumValueData,
262  InstrProfValueData ValueData[],
263  uint32_t &ActualNumValueData, uint64_t &TotalC,
264  bool GetNoICPValue = false);
265 
266 inline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; }
267 
268 /// Return the PGOFuncName meta data associated with a function.
269 MDNode *getPGOFuncNameMetadata(const Function &F);
270 
271 /// Create the PGOFuncName meta data if PGOFuncName is different from
272 /// function's raw name. This should only apply to internal linkage functions
273 /// declared by users only.
274 void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName);
275 
276 /// Check if we can use Comdat for profile variables. This will eliminate
277 /// the duplicated profile variables for Comdat functions.
278 bool needsComdatForCounter(const Function &F, const Module &M);
279 
281 
282 enum class instrprof_error {
283  success = 0,
284  eof,
286  bad_magic,
287  bad_header,
290  too_large,
291  truncated,
292  malformed,
298  invalid_prof,
307 };
308 
309 inline std::error_code make_error_code(instrprof_error E) {
310  return std::error_code(static_cast<int>(E), instrprof_category());
311 }
312 
313 class InstrProfError : public ErrorInfo<InstrProfError> {
314 public:
315  InstrProfError(instrprof_error Err, const Twine &ErrStr = Twine())
316  : Err(Err), Msg(ErrStr.str()) {
317  assert(Err != instrprof_error::success && "Not an error");
318  }
319 
320  std::string message() const override;
321 
322  void log(raw_ostream &OS) const override { OS << message(); }
323 
324  std::error_code convertToErrorCode() const override {
325  return make_error_code(Err);
326  }
327 
328  instrprof_error get() const { return Err; }
329  const std::string &getMessage() const { return Msg; }
330 
331  /// Consume an Error and return the raw enum value contained within it. The
332  /// Error must either be a success value, or contain a single InstrProfError.
334  auto Err = instrprof_error::success;
335  handleAllErrors(std::move(E), [&Err](const InstrProfError &IPE) {
336  assert(Err == instrprof_error::success && "Multiple errors encountered");
337  Err = IPE.get();
338  });
339  return Err;
340  }
341 
342  static char ID;
343 
344 private:
345  instrprof_error Err;
346  std::string Msg;
347 };
348 
350  /// Count the number of soft instrprof_errors encountered and keep track of
351  /// the first such error for reporting purposes.
352 
353  /// The first soft error encountered.
355 
356  /// The number of hash mismatches.
357  unsigned NumHashMismatches = 0;
358 
359  /// The number of count mismatches.
360  unsigned NumCountMismatches = 0;
361 
362  /// The number of counter overflows.
363  unsigned NumCounterOverflows = 0;
364 
365  /// The number of value site count mismatches.
366  unsigned NumValueSiteCountMismatches = 0;
367 
368 public:
369  SoftInstrProfErrors() = default;
370 
372  assert(FirstError == instrprof_error::success &&
373  "Unchecked soft error encountered");
374  }
375 
376  /// Track a soft error (\p IE) and increment its associated counter.
378 
379  /// Get the number of hash mismatches.
380  unsigned getNumHashMismatches() const { return NumHashMismatches; }
381 
382  /// Get the number of count mismatches.
383  unsigned getNumCountMismatches() const { return NumCountMismatches; }
384 
385  /// Get the number of counter overflows.
386  unsigned getNumCounterOverflows() const { return NumCounterOverflows; }
387 
388  /// Get the number of value site count mismatches.
390  return NumValueSiteCountMismatches;
391  }
392 
393  /// Return the first encountered error and reset FirstError to a success
394  /// value.
396  if (FirstError == instrprof_error::success)
397  return Error::success();
398  auto E = make_error<InstrProfError>(FirstError);
399  FirstError = instrprof_error::success;
400  return E;
401  }
402 };
403 
404 namespace object {
405 
406 class SectionRef;
407 
408 } // end namespace object
409 
410 namespace IndexedInstrProf {
411 
413 
414 } // end namespace IndexedInstrProf
415 
416 /// A symbol table used for function PGO name look-up with keys
417 /// (such as pointers, md5hash values) to the function. A function's
418 /// PGO name or name's md5hash are used in retrieving the profile
419 /// data of the function. See \c getPGOFuncName() method for details
420 /// on how PGO name is formed.
422 public:
423  using AddrHashMap = std::vector<std::pair<uint64_t, uint64_t>>;
424 
425 private:
426  StringRef Data;
427  uint64_t Address = 0;
428  // Unique name strings.
429  StringSet<> NameTab;
430  // A map from MD5 keys to function name strings.
431  std::vector<std::pair<uint64_t, StringRef>> MD5NameMap;
432  // A map from MD5 keys to function define. We only populate this map
433  // when build the Symtab from a Module.
434  std::vector<std::pair<uint64_t, Function *>> MD5FuncMap;
435  // A map from function runtime address to function name MD5 hash.
436  // This map is only populated and used by raw instr profile reader.
437  AddrHashMap AddrToMD5Map;
438  bool Sorted = false;
439 
440  static StringRef getExternalSymbol() {
441  return "** External Symbol **";
442  }
443 
444  // If the symtab is created by a series of calls to \c addFuncName, \c
445  // finalizeSymtab needs to be called before looking up function names.
446  // This is required because the underlying map is a vector (for space
447  // efficiency) which needs to be sorted.
448  inline void finalizeSymtab();
449 
450 public:
451  InstrProfSymtab() = default;
452 
453  /// Create InstrProfSymtab from an object file section which
454  /// contains function PGO names. When section may contain raw
455  /// string data or string data in compressed form. This method
456  /// only initialize the symtab with reference to the data and
457  /// the section base address. The decompression will be delayed
458  /// until before it is used. See also \c create(StringRef) method.
460 
461  /// This interface is used by reader of CoverageMapping test
462  /// format.
463  inline Error create(StringRef D, uint64_t BaseAddr);
464 
465  /// \c NameStrings is a string composed of one of more sub-strings
466  /// encoded in the format described in \c collectPGOFuncNameStrings.
467  /// This method is a wrapper to \c readPGOFuncNameStrings method.
468  inline Error create(StringRef NameStrings);
469 
470  /// A wrapper interface to populate the PGO symtab with functions
471  /// decls from module \c M. This interface is used by transformation
472  /// passes such as indirect function call promotion. Variable \c InLTO
473  /// indicates if this is called from LTO optimization passes.
474  Error create(Module &M, bool InLTO = false);
475 
476  /// Create InstrProfSymtab from a set of names iteratable from
477  /// \p IterRange. This interface is used by IndexedProfReader.
478  template <typename NameIterRange> Error create(const NameIterRange &IterRange);
479 
480  /// Update the symtab by adding \p FuncName to the table. This interface
481  /// is used by the raw and text profile readers.
483  if (FuncName.empty())
484  return make_error<InstrProfError>(instrprof_error::malformed,
485  "function name is empty");
486  auto Ins = NameTab.insert(FuncName);
487  if (Ins.second) {
488  MD5NameMap.push_back(std::make_pair(
489  IndexedInstrProf::ComputeHash(FuncName), Ins.first->getKey()));
490  Sorted = false;
491  }
492  return Error::success();
493  }
494 
495  /// Map a function address to its name's MD5 hash. This interface
496  /// is only used by the raw profiler reader.
498  AddrToMD5Map.push_back(std::make_pair(Addr, MD5Val));
499  }
500 
501  /// Return a function's hash, or 0, if the function isn't in this SymTab.
503 
504  /// Return function's PGO name from the function name's symbol
505  /// address in the object file. If an error occurs, return
506  /// an empty string.
507  StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize);
508 
509  /// Return function's PGO name from the name's md5 hash value.
510  /// If not found, return an empty string.
511  inline StringRef getFuncName(uint64_t FuncMD5Hash);
512 
513  /// Just like getFuncName, except that it will return a non-empty StringRef
514  /// if the function is external to this symbol table. All such cases
515  /// will be represented using the same StringRef value.
516  inline StringRef getFuncNameOrExternalSymbol(uint64_t FuncMD5Hash);
517 
518  /// True if Symbol is the value used to represent external symbols.
519  static bool isExternalSymbol(const StringRef &Symbol) {
520  return Symbol == InstrProfSymtab::getExternalSymbol();
521  }
522 
523  /// Return function from the name's md5 hash. Return nullptr if not found.
524  inline Function *getFunction(uint64_t FuncMD5Hash);
525 
526  /// Return the function's original assembly name by stripping off
527  /// the prefix attached (to symbols with priviate linkage). For
528  /// global functions, it returns the same string as getFuncName.
529  inline StringRef getOrigFuncName(uint64_t FuncMD5Hash);
530 
531  /// Return the name section data.
532  inline StringRef getNameData() const { return Data; }
533 };
534 
536  Data = D;
537  Address = BaseAddr;
538  return Error::success();
539 }
540 
542  return readPGOFuncNameStrings(NameStrings, *this);
543 }
544 
545 template <typename NameIterRange>
546 Error InstrProfSymtab::create(const NameIterRange &IterRange) {
547  for (auto Name : IterRange)
548  if (Error E = addFuncName(Name))
549  return E;
550 
551  finalizeSymtab();
552  return Error::success();
553 }
554 
555 void InstrProfSymtab::finalizeSymtab() {
556  if (Sorted)
557  return;
558  llvm::sort(MD5NameMap, less_first());
559  llvm::sort(MD5FuncMap, less_first());
560  llvm::sort(AddrToMD5Map, less_first());
561  AddrToMD5Map.erase(std::unique(AddrToMD5Map.begin(), AddrToMD5Map.end()),
562  AddrToMD5Map.end());
563  Sorted = true;
564 }
565 
567  StringRef ret = getFuncName(FuncMD5Hash);
568  if (ret.empty())
569  return InstrProfSymtab::getExternalSymbol();
570  return ret;
571 }
572 
574  finalizeSymtab();
575  auto Result = llvm::lower_bound(MD5NameMap, FuncMD5Hash,
576  [](const std::pair<uint64_t, StringRef> &LHS,
577  uint64_t RHS) { return LHS.first < RHS; });
578  if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
579  return Result->second;
580  return StringRef();
581 }
582 
584  finalizeSymtab();
585  auto Result = llvm::lower_bound(MD5FuncMap, FuncMD5Hash,
586  [](const std::pair<uint64_t, Function *> &LHS,
587  uint64_t RHS) { return LHS.first < RHS; });
588  if (Result != MD5FuncMap.end() && Result->first == FuncMD5Hash)
589  return Result->second;
590  return nullptr;
591 }
592 
593 // See also getPGOFuncName implementation. These two need to be
594 // matched.
596  StringRef PGOName = getFuncName(FuncMD5Hash);
597  size_t S = PGOName.find_first_of(':');
598  if (S == StringRef::npos)
599  return PGOName;
600  return PGOName.drop_front(S + 1);
601 }
602 
603 // To store the sums of profile count values, or the percentage of
604 // the sums of the total count values.
607  double CountSum;
608  double ValueCounts[IPVK_Last - IPVK_First + 1];
610  void reset() {
611  NumEntries = 0;
612  CountSum = 0.0f;
613  for (unsigned I = 0; I < IPVK_Last - IPVK_First + 1; I++)
614  ValueCounts[I] = 0.0f;
615  }
616 };
617 
618 // Function level or program level overlap information.
619 struct OverlapStats {
621  // Sum of the total count values for the base profile.
623  // Sum of the total count values for the test profile.
625  // Overlap lap score. Should be in range of [0.0f to 1.0f].
630  const std::string *BaseFilename;
631  const std::string *TestFilename;
634  bool Valid;
635 
637  : Level(L), BaseFilename(nullptr), TestFilename(nullptr), FuncHash(0),
638  Valid(false) {}
639 
640  void dump(raw_fd_ostream &OS) const;
641 
643  FuncName = Name;
644  FuncHash = Hash;
645  }
646 
647  Error accumulateCounts(const std::string &BaseFilename,
648  const std::string &TestFilename, bool IsCS);
649  void addOneMismatch(const CountSumOrPercent &MismatchFunc);
650  void addOneUnique(const CountSumOrPercent &UniqueFunc);
651 
652  static inline double score(uint64_t Val1, uint64_t Val2, double Sum1,
653  double Sum2) {
654  if (Sum1 < 1.0f || Sum2 < 1.0f)
655  return 0.0f;
656  return std::min(Val1 / Sum1, Val2 / Sum2);
657  }
658 };
659 
660 // This is used to filter the functions whose overlap information
661 // to be output.
664  const std::string NameFilter;
665 };
666 
668  /// Value profiling data pairs at a given value site.
669  std::list<InstrProfValueData> ValueData;
670 
672  template <class InputIterator>
673  InstrProfValueSiteRecord(InputIterator F, InputIterator L)
674  : ValueData(F, L) {}
675 
676  /// Sort ValueData ascending by Value
678  ValueData.sort(
679  [](const InstrProfValueData &left, const InstrProfValueData &right) {
680  return left.Value < right.Value;
681  });
682  }
683  /// Sort ValueData Descending by Count
684  inline void sortByCount();
685 
686  /// Merge data from another InstrProfValueSiteRecord
687  /// Optionally scale merged counts by \p Weight.
688  void merge(InstrProfValueSiteRecord &Input, uint64_t Weight,
689  function_ref<void(instrprof_error)> Warn);
690  /// Scale up value profile data counts by N (Numerator) / D (Denominator).
691  void scale(uint64_t N, uint64_t D, function_ref<void(instrprof_error)> Warn);
692 
693  /// Compute the overlap b/w this record and Input record.
695  OverlapStats &Overlap, OverlapStats &FuncLevelOverlap);
696 };
697 
698 /// Profiling information for a single function.
700  std::vector<uint64_t> Counts;
701 
702  InstrProfRecord() = default;
703  InstrProfRecord(std::vector<uint64_t> Counts) : Counts(std::move(Counts)) {}
704  InstrProfRecord(InstrProfRecord &&) = default;
706  : Counts(RHS.Counts),
707  ValueData(RHS.ValueData
708  ? std::make_unique<ValueProfData>(*RHS.ValueData)
709  : nullptr) {}
712  Counts = RHS.Counts;
713  if (!RHS.ValueData) {
714  ValueData = nullptr;
715  return *this;
716  }
717  if (!ValueData)
718  ValueData = std::make_unique<ValueProfData>(*RHS.ValueData);
719  else
720  *ValueData = *RHS.ValueData;
721  return *this;
722  }
723 
724  /// Return the number of value profile kinds with non-zero number
725  /// of profile sites.
726  inline uint32_t getNumValueKinds() const;
727  /// Return the number of instrumented sites for ValueKind.
729 
730  /// Return the total number of ValueData for ValueKind.
732 
733  /// Return the number of value data collected for ValueKind at profiling
734  /// site: Site.
736  uint32_t Site) const;
737 
738  /// Return the array of profiled values at \p Site. If \p TotalC
739  /// is not null, the total count of all target values at this site
740  /// will be stored in \c *TotalC.
741  inline std::unique_ptr<InstrProfValueData[]>
743  uint64_t *TotalC = nullptr) const;
744 
745  /// Get the target value/counts of kind \p ValueKind collected at site
746  /// \p Site and store the result in array \p Dest. Return the total
747  /// counts of all target values at this site.
748  inline uint64_t getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind,
749  uint32_t Site) const;
750 
751  /// Reserve space for NumValueSites sites.
752  inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
753 
754  /// Add ValueData for ValueKind at value Site.
756  InstrProfValueData *VData, uint32_t N,
757  InstrProfSymtab *SymTab);
758 
759  /// Merge the counts in \p Other into this one.
760  /// Optionally scale merged counts by \p Weight.
761  void merge(InstrProfRecord &Other, uint64_t Weight,
762  function_ref<void(instrprof_error)> Warn);
763 
764  /// Scale up profile counts (including value profile data) by
765  /// a factor of (N / D).
766  void scale(uint64_t N, uint64_t D, function_ref<void(instrprof_error)> Warn);
767 
768  /// Sort value profile data (per site) by count.
769  void sortValueData() {
770  for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
771  for (auto &SR : getValueSitesForKind(Kind))
772  SR.sortByCount();
773  }
774 
775  /// Clear value data entries and edge counters.
776  void Clear() {
777  Counts.clear();
778  clearValueData();
779  }
780 
781  /// Clear value data entries
782  void clearValueData() { ValueData = nullptr; }
783 
784  /// Compute the sums of all counts and store in Sum.
785  void accumulateCounts(CountSumOrPercent &Sum) const;
786 
787  /// Compute the overlap b/w this IntrprofRecord and Other.
788  void overlap(InstrProfRecord &Other, OverlapStats &Overlap,
789  OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff);
790 
791  /// Compute the overlap of value profile counts.
793  OverlapStats &Overlap,
794  OverlapStats &FuncLevelOverlap);
795 
796 private:
797  struct ValueProfData {
798  std::vector<InstrProfValueSiteRecord> IndirectCallSites;
799  std::vector<InstrProfValueSiteRecord> MemOPSizes;
800  };
801  std::unique_ptr<ValueProfData> ValueData;
802 
803  MutableArrayRef<InstrProfValueSiteRecord>
804  getValueSitesForKind(uint32_t ValueKind) {
805  // Cast to /add/ const (should be an implicit_cast, ideally, if that's ever
806  // implemented in LLVM) to call the const overload of this function, then
807  // cast away the constness from the result.
808  auto AR = const_cast<const InstrProfRecord *>(this)->getValueSitesForKind(
809  ValueKind);
810  return makeMutableArrayRef(
811  const_cast<InstrProfValueSiteRecord *>(AR.data()), AR.size());
812  }
813  ArrayRef<InstrProfValueSiteRecord>
814  getValueSitesForKind(uint32_t ValueKind) const {
815  if (!ValueData)
816  return None;
817  switch (ValueKind) {
818  case IPVK_IndirectCallTarget:
819  return ValueData->IndirectCallSites;
820  case IPVK_MemOPSize:
821  return ValueData->MemOPSizes;
822  default:
823  llvm_unreachable("Unknown value kind!");
824  }
825  }
826 
827  std::vector<InstrProfValueSiteRecord> &
828  getOrCreateValueSitesForKind(uint32_t ValueKind) {
829  if (!ValueData)
830  ValueData = std::make_unique<ValueProfData>();
831  switch (ValueKind) {
832  case IPVK_IndirectCallTarget:
833  return ValueData->IndirectCallSites;
834  case IPVK_MemOPSize:
835  return ValueData->MemOPSizes;
836  default:
837  llvm_unreachable("Unknown value kind!");
838  }
839  }
840 
841  // Map indirect call target name hash to name string.
843  InstrProfSymtab *SymTab);
844 
845  // Merge Value Profile data from Src record to this record for ValueKind.
846  // Scale merged value counts by \p Weight.
847  void mergeValueProfData(uint32_t ValkeKind, InstrProfRecord &Src,
848  uint64_t Weight,
849  function_ref<void(instrprof_error)> Warn);
850 
851  // Scale up value profile data count by N (Numerator) / D (Denominator).
852  void scaleValueProfData(uint32_t ValueKind, uint64_t N, uint64_t D,
853  function_ref<void(instrprof_error)> Warn);
854 };
855 
859 
860  // We reserve this bit as the flag for context sensitive profile record.
861  static const int CS_FLAG_IN_FUNC_HASH = 60;
862 
863  NamedInstrProfRecord() = default;
865  std::vector<uint64_t> Counts)
867 
868  static bool hasCSFlagInHash(uint64_t FuncHash) {
869  return ((FuncHash >> CS_FLAG_IN_FUNC_HASH) & 1);
870  }
871  static void setCSFlagInHash(uint64_t &FuncHash) {
872  FuncHash |= ((uint64_t)1 << CS_FLAG_IN_FUNC_HASH);
873  }
874 };
875 
877  uint32_t NumValueKinds = 0;
878  for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
879  NumValueKinds += !(getValueSitesForKind(Kind).empty());
880  return NumValueKinds;
881 }
882 
884  uint32_t N = 0;
885  for (auto &SR : getValueSitesForKind(ValueKind))
886  N += SR.ValueData.size();
887  return N;
888 }
889 
891  return getValueSitesForKind(ValueKind).size();
892 }
893 
895  uint32_t Site) const {
896  return getValueSitesForKind(ValueKind)[Site].ValueData.size();
897 }
898 
899 std::unique_ptr<InstrProfValueData[]>
901  uint64_t *TotalC) const {
902  uint64_t Dummy = 0;
903  uint64_t &TotalCount = (TotalC == nullptr ? Dummy : *TotalC);
905  if (N == 0) {
906  TotalCount = 0;
907  return std::unique_ptr<InstrProfValueData[]>(nullptr);
908  }
909 
910  auto VD = std::make_unique<InstrProfValueData[]>(N);
911  TotalCount = getValueForSite(VD.get(), ValueKind, Site);
912 
913  return VD;
914 }
915 
916 uint64_t InstrProfRecord::getValueForSite(InstrProfValueData Dest[],
918  uint32_t Site) const {
919  uint32_t I = 0;
920  uint64_t TotalCount = 0;
921  for (auto V : getValueSitesForKind(ValueKind)[Site].ValueData) {
922  Dest[I].Value = V.Value;
923  Dest[I].Count = V.Count;
924  TotalCount = SaturatingAdd(TotalCount, V.Count);
925  I++;
926  }
927  return TotalCount;
928 }
929 
931  if (!NumValueSites)
932  return;
933  getOrCreateValueSitesForKind(ValueKind).reserve(NumValueSites);
934 }
935 
938 }
939 
940 // Include definitions for value profile data
941 #define INSTR_PROF_VALUE_PROF_DATA
943 
945  ValueData.sort(
946  [](const InstrProfValueData &left, const InstrProfValueData &right) {
947  return left.Count > right.Count;
948  });
949  // Now truncate
950  size_t max_s = INSTR_PROF_MAX_NUM_VAL_PER_SITE;
951  if (ValueData.size() > max_s)
952  ValueData.resize(max_s);
953 }
954 
955 namespace IndexedInstrProf {
956 
957 enum class HashT : uint32_t {
958  MD5,
959  Last = MD5
960 };
961 
963  switch (Type) {
964  case HashT::MD5:
965  return MD5Hash(K);
966  }
967  llvm_unreachable("Unhandled hash type");
968 }
969 
970 const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81"
971 
973  // Version 1 is the first version. In this version, the value of
974  // a key/value pair can only include profile data of a single function.
975  // Due to this restriction, the number of block counters for a given
976  // function is not recorded but derived from the length of the value.
977  Version1 = 1,
978  // The version 2 format supports recording profile data of multiple
979  // functions which share the same key in one value field. To support this,
980  // the number block counters is recorded as an uint64_t field right after the
981  // function structural hash.
982  Version2 = 2,
983  // Version 3 supports value profile data. The value profile data is expected
984  // to follow the block counter profile data.
985  Version3 = 3,
986  // In this version, profile summary data \c IndexedInstrProf::Summary is
987  // stored after the profile header.
988  Version4 = 4,
989  // In this version, the frontend PGO stable hash algorithm defaults to V2.
990  Version5 = 5,
991  // In this version, the frontend PGO stable hash algorithm got fixed and
992  // may produce hashes different from Version5.
993  Version6 = 6,
994  // An additional counter is added around logical operators.
995  Version7 = 7,
996  // The current version is 7.
997  CurrentVersion = INSTR_PROF_INDEX_VERSION
998 };
1000 
1002 
1004 
1005 // This structure defines the file header of the LLVM profile
1006 // data file in indexed-format.
1007 struct Header {
1010  uint64_t Unused; // Becomes unused since version 4
1013 };
1014 
1015 // Profile summary data recorded in the profile data file in indexed
1016 // format. It is introduced in version 4. The summary data follows
1017 // right after the profile file header.
1018 struct Summary {
1019  struct Entry {
1020  uint64_t Cutoff; ///< The required percentile of total execution count.
1021  uint64_t
1022  MinBlockCount; ///< The minimum execution count for this percentile.
1023  uint64_t NumBlocks; ///< Number of blocks >= the minumum execution count.
1024  };
1025  // The field kind enumerator to assigned value mapping should remain
1026  // unchanged when a new kind is added or an old kind gets deleted in
1027  // the future.
1029  /// The total number of functions instrumented.
1031  /// Total number of instrumented blocks/edges.
1033  /// The maximal execution count among all functions.
1034  /// This field does not exist for profile data from IR based
1035  /// instrumentation.
1037  /// Max block count of the program.
1039  /// Max internal block count of the program (excluding entry blocks).
1041  /// The sum of all instrumented block counts.
1044  };
1045 
1046  // The number of summmary fields following the summary header.
1048  // The number of Cutoff Entries (Summary::Entry) following summary fields.
1050 
1051  Summary() = delete;
1052  Summary(uint32_t Size) { memset(this, 0, Size); }
1053 
1054  void operator delete(void *ptr) { ::operator delete(ptr); }
1055 
1057  return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
1058  NumSumFields * sizeof(uint64_t);
1059  }
1060 
1061  const uint64_t *getSummaryDataBase() const {
1062  return reinterpret_cast<const uint64_t *>(this + 1);
1063  }
1064 
1066  return reinterpret_cast<uint64_t *>(this + 1);
1067  }
1068 
1069  const Entry *getCutoffEntryBase() const {
1070  return reinterpret_cast<const Entry *>(
1072  }
1073 
1075  return reinterpret_cast<Entry *>(&getSummaryDataBase()[NumSummaryFields]);
1076  }
1077 
1079  return getSummaryDataBase()[K];
1080  }
1081 
1083  getSummaryDataBase()[K] = V;
1084  }
1085 
1086  const Entry &getEntry(uint32_t I) const { return getCutoffEntryBase()[I]; }
1087 
1089  Entry &ER = getCutoffEntryBase()[I];
1090  ER.Cutoff = E.Cutoff;
1091  ER.MinBlockCount = E.MinCount;
1092  ER.NumBlocks = E.NumCounts;
1093  }
1094 };
1095 
1096 inline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) {
1097  return std::unique_ptr<Summary>(new (::operator new(TotalSize))
1098  Summary(TotalSize));
1099 }
1100 
1101 } // end namespace IndexedInstrProf
1102 
1103 namespace RawInstrProf {
1104 
1105 // Version 1: First version
1106 // Version 2: Added value profile data section. Per-function control data
1107 // struct has more fields to describe value profile information.
1108 // Version 3: Compressed name section support. Function PGO name reference
1109 // from control data struct is changed from raw pointer to Name's MD5 value.
1110 // Version 4: ValueDataBegin and ValueDataSizes fields are removed from the
1111 // raw header.
1112 // Version 5: Bit 60 of FuncHash is reserved for the flag for the context
1113 // sensitive records.
1114 // Version 6: Added binary id.
1115 // Version 7: Reorder binary id and include version in signature.
1116 // Version 8: Use relative counter pointer.
1117 const uint64_t Version = INSTR_PROF_RAW_VERSION;
1118 
1119 template <class IntPtrT> inline uint64_t getMagic();
1120 template <> inline uint64_t getMagic<uint64_t>() {
1121  return INSTR_PROF_RAW_MAGIC_64;
1122 }
1123 
1124 template <> inline uint64_t getMagic<uint32_t>() {
1125  return INSTR_PROF_RAW_MAGIC_32;
1126 }
1127 
1128 // Per-function profile data header/control structure.
1129 // The definition should match the structure defined in
1130 // compiler-rt/lib/profile/InstrProfiling.h.
1131 // It should also match the synthesized type in
1132 // Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters.
1133 template <class IntPtrT> struct alignas(8) ProfileData {
1134  #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
1136 };
1137 
1138 // File header structure of the LLVM profile data in raw format.
1139 // The definition should match the header referenced in
1140 // compiler-rt/lib/profile/InstrProfilingFile.c and
1141 // InstrProfilingBuffer.c.
1142 struct Header {
1143 #define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name;
1145 };
1146 
1147 } // end namespace RawInstrProf
1148 
1149 // Parse MemOP Size range option.
1150 void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart,
1151  int64_t &RangeLast);
1152 
1153 // Create a COMDAT variable INSTR_PROF_RAW_VERSION_VAR to make the runtime
1154 // aware this is an ir_level profile so it can set the version flag.
1155 GlobalVariable *createIRLevelProfileFlagVar(Module &M, bool IsCS,
1156  bool InstrEntryBBEnabled,
1157  bool DebugInfoCorrelate);
1158 
1159 // Create the variable for the profile file name.
1160 void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput);
1161 
1162 // Whether to compress function names in profile records, and filenames in
1163 // code coverage mappings. Used by the Instrumentation library and unit tests.
1164 extern cl::opt<bool> DoInstrProfNameCompression;
1165 
1166 } // end namespace llvm
1167 #endif // LLVM_PROFILEDATA_INSTRPROF_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::getMemOPSizeRangeFromOption
void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart, int64_t &RangeLast)
llvm::OverlapStats::Unique
CountSumOrPercent Unique
Definition: InstrProf.h:628
llvm::OverlapStats::Level
OverlapStatsLevel Level
Definition: InstrProf.h:629
llvm::createPGOFuncNameMetadata
void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
Definition: InstrProf.cpp:1105
llvm::OverlapStats::score
static double score(uint64_t Val1, uint64_t Val2, double Sum1, double Sum2)
Definition: InstrProf.h:652
llvm::instrprof_error::bad_header
@ bad_header
llvm::SoftInstrProfErrors::SoftInstrProfErrors
SoftInstrProfErrors()=default
right
the custom lowered code happens to be right
Definition: README-SSE.txt:480
llvm::IndexedInstrProf::Summary::getCutoffEntryBase
const Entry * getCutoffEntryBase() const
Definition: InstrProf.h:1069
MathExtras.h
llvm::InstrProfRecord::InstrProfRecord
InstrProfRecord()=default
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::IndexedInstrProf::ProfVersion
ProfVersion
Definition: InstrProf.h:972
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::SaturatingAdd
std::enable_if_t< std::is_unsigned< T >::value, T > SaturatingAdd(T X, T Y, bool *ResultOverflowed=nullptr)
Add two unsigned integers, X and Y, of type T.
Definition: MathExtras.h:803
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::IndexedInstrProf::Header::Version
uint64_t Version
Definition: InstrProf.h:1009
llvm::createIRLevelProfileFlagVar
GlobalVariable * createIRLevelProfileFlagVar(Module &M, bool IsCS, bool InstrEntryBBEnabled, bool DebugInfoCorrelate)
Definition: InstrProf.cpp:1189
llvm::getInstrProfNamesVarName
StringRef getInstrProfNamesVarName()
Return the name of the variable holding the strings (possibly compressed) of all function's PGO names...
Definition: InstrProf.h:100
llvm::OverlapStats::Valid
bool Valid
Definition: InstrProf.h:634
llvm::InstrProfRecord::operator=
InstrProfRecord & operator=(const InstrProfRecord &RHS)
Definition: InstrProf.h:711
llvm::InstrProfError::message
std::string message() const override
Return the error message as a string.
Definition: InstrProf.cpp:260
llvm::instrprof_error::uncompress_failed
@ uncompress_failed
llvm::Function
Definition: Function.h:62
ProfileSummary.h
llvm::lower_bound
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1759
StringRef.h
llvm::IndexedInstrProf::Summary::Entry::NumBlocks
uint64_t NumBlocks
Number of blocks >= the minumum execution count.
Definition: InstrProf.h:1023
llvm::IndexedInstrProf::Version7
@ Version7
Definition: InstrProf.h:995
llvm::InstrProfRecord::getValueForSite
std::unique_ptr< InstrProfValueData[]> getValueForSite(uint32_t ValueKind, uint32_t Site, uint64_t *TotalC=nullptr) const
Return the array of profiled values at Site.
Definition: InstrProf.h:900
llvm::needsComdatForCounter
bool needsComdatForCounter(const Function &F, const Module &M)
Check if we can use Comdat for profile variables.
Definition: InstrProf.cpp:1117
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:59
Host.h
llvm::getPGOFuncNameVarInitializer
StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
Definition: InstrProf.cpp:483
llvm::IndexedInstrProf::ComputeHash
uint64_t ComputeHash(StringRef K)
Definition: InstrProf.h:1003
llvm::OverlapStats::FunctionLevel
@ FunctionLevel
Definition: InstrProf.h:620
llvm::getPGOFuncName
std::string getPGOFuncName(const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Return the modified name for function F suitable to be used the key for profile lookup.
Definition: InstrProf.cpp:304
ErrorHandling.h
llvm::InstrProfSymtab::create
Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
llvm::OverlapStats::dump
void dump(raw_fd_ostream &OS) const
Definition: InstrProf.cpp:1274
llvm::InstrProfError::get
instrprof_error get() const
Definition: InstrProf.h:328
llvm::InstrProfRecord::Clear
void Clear()
Clear value data entries and edge counters.
Definition: InstrProf.h:776
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::IndexedInstrProf::HashT::MD5
@ MD5
llvm::getInstrProfNameSeparator
StringRef getInstrProfNameSeparator()
Return the marker used to separate PGO names during serialization.
Definition: InstrProf.h:163
Error.h
llvm::createPGOFuncNameVar
GlobalVariable * createPGOFuncNameVar(Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
Definition: InstrProf.cpp:383
llvm::IndexedInstrProf::Summary::getEntry
const Entry & getEntry(uint32_t I) const
Definition: InstrProf.h:1086
llvm::getInstrProfRuntimeHookVarName
StringRef getInstrProfRuntimeHookVarName()
Return the name of the hook variable defined in profile runtime library.
Definition: InstrProf.h:148
llvm::InstrProfRecord::operator=
InstrProfRecord & operator=(InstrProfRecord &&)=default
llvm::COFF::NameSize
@ NameSize
Definition: COFF.h:58
llvm::IndexedInstrProf::Summary::Entry
Definition: InstrProf.h:1019
llvm::IndexedInstrProf::Summary::NumKinds
@ NumKinds
Definition: InstrProf.h:1043
llvm::instrprof_error::zlib_unavailable
@ zlib_unavailable
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::OverlapStats
Definition: InstrProf.h:619
llvm::InstrProfValueSiteRecord::scale
void scale(uint64_t N, uint64_t D, function_ref< void(instrprof_error)> Warn)
Scale up value profile data counts by N (Numerator) / D (Denominator).
Definition: InstrProf.cpp:687
llvm::InstrProfRecord::overlap
void overlap(InstrProfRecord &Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff)
Compute the overlap b/w this IntrprofRecord and Other.
Definition: InstrProf.cpp:614
llvm::InstrProfRecord::clearValueData
void clearValueData()
Clear value data entries.
Definition: InstrProf.h:782
llvm::InstrProfValueSiteRecord::InstrProfValueSiteRecord
InstrProfValueSiteRecord()
Definition: InstrProf.h:671
llvm::SoftInstrProfErrors::getNumCountMismatches
unsigned getNumCountMismatches() const
Get the number of count mismatches.
Definition: InstrProf.h:383
llvm::getInstrProfNamesRegFuncName
StringRef getInstrProfNamesRegFuncName()
Return the name of the runtime interface that registers the PGO name strings.
Definition: InstrProf.h:135
llvm::instrprof_error::value_site_count_mismatch
@ value_site_count_mismatch
ret
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
llvm::RawInstrProf::getMagic
uint64_t getMagic()
llvm::InstrProfSymtab::InstrProfSymtab
InstrProfSymtab()=default
llvm::StringSet::insert
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition: StringSet.h:33
llvm::InstrProfError::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: InstrProf.h:324
llvm::NamedInstrProfRecord::NamedInstrProfRecord
NamedInstrProfRecord(StringRef Name, uint64_t Hash, std::vector< uint64_t > Counts)
Definition: InstrProf.h:864
STLExtras.h
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::InstrProfValueSiteRecord::sortByCount
void sortByCount()
Sort ValueData Descending by Count.
Definition: InstrProf.h:944
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::getPGOFuncNameVarName
std::string getPGOFuncNameVarName(StringRef FuncName, GlobalValue::LinkageTypes Linkage)
Return the name of the global variable used to store a function name in PGO instrumentation.
Definition: InstrProf.cpp:338
llvm::createProfileFileNameVar
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
Definition: InstrProf.cpp:1214
llvm::instrprof_error::invalid_prof
@ invalid_prof
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::InstrProfError::InstrProfError
InstrProfError(instrprof_error Err, const Twine &ErrStr=Twine())
Definition: InstrProf.h:315
llvm::CountSumOrPercent::CountSumOrPercent
CountSumOrPercent()
Definition: InstrProf.h:609
llvm::InstrProfRecord
Profiling information for a single function.
Definition: InstrProf.h:699
llvm::IndexedInstrProf::Summary::Summary
Summary(uint32_t Size)
Definition: InstrProf.h:1052
F
#define F(x, y, z)
Definition: MD5.cpp:55
InstrProfData.inc
llvm::NamedInstrProfRecord::CS_FLAG_IN_FUNC_HASH
static const int CS_FLAG_IN_FUNC_HASH
Definition: InstrProf.h:861
llvm::InstrProfValueSiteRecord::merge
void merge(InstrProfValueSiteRecord &Input, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge data from another InstrProfValueSiteRecord Optionally scale merged counts by Weight.
Definition: InstrProf.cpp:665
llvm::IndexedInstrProf::Summary::getCutoffEntryBase
Entry * getCutoffEntryBase()
Definition: InstrProf.h:1074
llvm::IndexedInstrProf::Version5
@ Version5
Definition: InstrProf.h:990
llvm::instrprof_error::unexpected_debug_info_for_correlation
@ unexpected_debug_info_for_correlation
llvm::OverlapStats::TestFilename
const std::string * TestFilename
Definition: InstrProf.h:631
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:82
llvm::IndexedInstrProf::Version4
@ Version4
Definition: InstrProf.h:988
llvm::OverlapFuncFilters
Definition: InstrProf.h:662
llvm::IndexedInstrProf::Summary::getSummaryDataBase
uint64_t * getSummaryDataBase()
Definition: InstrProf.h:1065
CommandLine.h
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
llvm::AMDGPU::HSAMD::ValueKind
ValueKind
Value kinds.
Definition: AMDGPUMetadata.h:73
llvm::NamedInstrProfRecord::NamedInstrProfRecord
NamedInstrProfRecord()=default
GlobalValue.h
llvm::InstrProfRecord::getNumValueDataForSite
uint32_t getNumValueDataForSite(uint32_t ValueKind, uint32_t Site) const
Return the number of value data collected for ValueKind at profiling site: Site.
Definition: InstrProf.h:894
MD5.h
llvm::CountSumOrPercent::CountSum
double CountSum
Definition: InstrProf.h:607
llvm::RawInstrProf::getMagic< uint32_t >
uint64_t getMagic< uint32_t >()
Definition: InstrProf.h:1124
f
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::getInstrProfValuesVarPrefix
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
Definition: InstrProf.h:93
llvm::support::little
@ little
Definition: Endian.h:27
llvm::less_first
Function object to check whether the first component of a std::pair compares less than the first comp...
Definition: STLExtras.h:1376
llvm::SoftInstrProfErrors::getNumCounterOverflows
unsigned getNumCounterOverflows() const
Get the number of counter overflows.
Definition: InstrProf.h:386
llvm::InstrProfError::getMessage
const std::string & getMessage() const
Definition: InstrProf.h:329
llvm::canRenameComdatFunc
bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
Definition: InstrProf.cpp:1165
llvm::instrprof_error::compress_failed
@ compress_failed
llvm::InstrProfRecord::getNumValueSites
uint32_t getNumValueSites(uint32_t ValueKind) const
Return the number of instrumented sites for ValueKind.
Definition: InstrProf.h:890
llvm::getInstrProfCountersVarPrefix
StringRef getInstrProfCountersVarPrefix()
Return the name prefix of profile counter variables.
Definition: InstrProf.h:90
false
Definition: StackSlotColoring.cpp:142
llvm::InstrProfError::ID
static char ID
Definition: InstrProf.h:342
llvm::getInstrProfInitFuncName
StringRef getInstrProfInitFuncName()
Return the name of the runtime initialization method that is generated by the compiler.
Definition: InstrProf.h:143
llvm::InstrProfSymtab::getFunction
Function * getFunction(uint64_t FuncMD5Hash)
Return function from the name's md5 hash. Return nullptr if not found.
Definition: InstrProf.h:583
llvm::RawInstrProf::getMagic< uint64_t >
uint64_t getMagic< uint64_t >()
Definition: InstrProf.h:1120
llvm::instrprof_error::truncated
@ truncated
llvm::IndexedInstrProf::Header::Magic
uint64_t Magic
Definition: InstrProf.h:1008
llvm::getCoverageMappingVarName
StringRef getCoverageMappingVarName()
Return the name of a covarage mapping variable (internal linkage) for each instrumented source module...
Definition: InstrProf.h:107
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::SoftInstrProfErrors::takeError
Error takeError()
Return the first encountered error and reset FirstError to a success value.
Definition: InstrProf.h:395
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:999
llvm::OverlapStats::FuncName
StringRef FuncName
Definition: InstrProf.h:632
llvm::IndexedInstrProf::Header
Definition: InstrProf.h:1007
llvm::instrprof_error::bad_magic
@ bad_magic
llvm::IndexedInstrProf::Summary::TotalBlockCount
@ TotalBlockCount
The sum of all instrumented block counts.
Definition: InstrProf.h:1042
llvm::instrprof_error::unsupported_version
@ unsupported_version
llvm::None
const NoneType None
Definition: None.h:23
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::instrprof_error::too_large
@ too_large
llvm::InstrProfError::take
static instrprof_error take(Error E)
Consume an Error and return the raw enum value contained within it.
Definition: InstrProf.h:333
llvm::InstrProfSectKind
InstrProfSectKind
Definition: InstrProf.h:57
llvm::InstrProfSymtab::AddrHashMap
std::vector< std::pair< uint64_t, uint64_t > > AddrHashMap
Definition: InstrProf.h:423
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
llvm::getInstrProfVNodesVarName
StringRef getInstrProfVNodesVarName()
Return the name of value profile node array variables:
Definition: InstrProf.h:96
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:79
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:223
llvm::getHostEndianness
support::endianness getHostEndianness()
Definition: InstrProf.h:936
llvm::IndexedInstrProf::Summary::MaxFunctionCount
@ MaxFunctionCount
The maximal execution count among all functions.
Definition: InstrProf.h:1036
llvm::IndexedInstrProf::Summary::get
uint64_t get(SummaryFieldKind K) const
Definition: InstrProf.h:1078
llvm::instrprof_error::unsupported_hash_type
@ unsupported_hash_type
llvm::getInstrProfNameVarPrefix
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
Definition: InstrProf.h:84
llvm::CountSumOrPercent::NumEntries
uint64_t NumEntries
Definition: InstrProf.h:606
llvm::IndexedInstrProf::Summary::set
void set(SummaryFieldKind K, uint64_t V)
Definition: InstrProf.h:1082
llvm::NamedInstrProfRecord::Name
StringRef Name
Definition: InstrProf.h:857
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::StringRef::empty
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:152
uint64_t
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::NamedInstrProfRecord::Hash
uint64_t Hash
Definition: InstrProf.h:858
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::IndexedInstrProf::CurrentVersion
@ CurrentVersion
Definition: InstrProf.h:997
llvm::IndexedInstrProf::Summary::getSize
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries)
Definition: InstrProf.h:1056
llvm::SoftInstrProfErrors::addError
void addError(instrprof_error IE)
Track a soft error (IE) and increment its associated counter.
Definition: InstrProf.cpp:235
llvm::InstrProfError
Definition: InstrProf.h:313
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::MD5
Definition: MD5.h:41
llvm::CountSumOrPercent
Definition: InstrProf.h:605
llvm::isIRPGOFlagSet
bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
Definition: InstrProf.cpp:1143
llvm::instrprof_error::empty_raw_profile
@ empty_raw_profile
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::OverlapStats::OverlapStatsLevel
OverlapStatsLevel
Definition: InstrProf.h:620
llvm::instrprof_error
instrprof_error
Definition: InstrProf.h:282
llvm::instrprof_error::success
@ success
ArrayRef.h
llvm::getInstrProfRuntimeHookVarUseFuncName
StringRef getInstrProfRuntimeHookVarUseFuncName()
Return the name of the compiler generated function that references the runtime hook variable.
Definition: InstrProf.h:154
llvm::IndexedInstrProf::Header::HashType
uint64_t HashType
Definition: InstrProf.h:1011
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1707
llvm::instrprof_error::unknown_function
@ unknown_function
llvm::IndexedInstrProf::HashT::Last
@ Last
llvm::instrprof_error::unrecognized_format
@ unrecognized_format
llvm::IndexedInstrProf::Summary::SummaryFieldKind
SummaryFieldKind
Definition: InstrProf.h:1028
llvm::IndexedInstrProf::allocSummary
std::unique_ptr< Summary > allocSummary(uint32_t TotalSize)
Definition: InstrProf.h:1096
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::InstrProfValueKind
InstrProfValueKind
Definition: InstrProf.h:238
llvm::ErrorInfo
Base class for user error types.
Definition: Error.h:349
llvm::IndexedInstrProf::Summary::TotalNumFunctions
@ TotalNumFunctions
The total number of functions instrumented.
Definition: InstrProf.h:1030
llvm::InstrProfSymtab::getOrigFuncName
StringRef getOrigFuncName(uint64_t FuncMD5Hash)
Return the function's original assembly name by stripping off the prefix attached (to symbols with pr...
Definition: InstrProf.h:595
llvm::collectPGOFuncNameStrings
Error collectPGOFuncNameStrings(ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (function PGO names) NameStrs, the method generates a combined string Resul...
Definition: InstrProf.cpp:442
llvm::OverlapStats::OverlapStats
OverlapStats(OverlapStatsLevel L=ProgramLevel)
Definition: InstrProf.h:636
llvm::SoftInstrProfErrors::getNumValueSiteCountMismatches
unsigned getNumValueSiteCountMismatches() const
Get the number of value site count mismatches.
Definition: InstrProf.h:389
llvm::IndexedInstrProf::Version6
@ Version6
Definition: InstrProf.h:993
llvm::InstrProfSymtab::getFunctionHashFromAddress
uint64_t getFunctionHashFromAddress(uint64_t Address)
Return a function's hash, or 0, if the function isn't in this SymTab.
Definition: InstrProf.cpp:428
Triple.h
llvm::InstrProfError::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: InstrProf.h:322
llvm::StringSet
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:22
llvm::IndexedInstrProf::Summary::setEntry
void setEntry(uint32_t I, const ProfileSummaryEntry &E)
Definition: InstrProf.h:1088
llvm::getInstrProfRegFuncsName
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
Definition: InstrProf.h:124
llvm::NVPTXISD::Dummy
@ Dummy
Definition: NVPTXISelLowering.h:60
llvm::InstrProfRecord::accumulateCounts
void accumulateCounts(CountSumOrPercent &Sum) const
Compute the sums of all counts and store in Sum.
Definition: InstrProf.cpp:545
llvm::OverlapStats::addOneUnique
void addOneUnique(const CountSumOrPercent &UniqueFunc)
Definition: InstrProf.cpp:1265
llvm::InstrProfSymtab::isExternalSymbol
static bool isExternalSymbol(const StringRef &Symbol)
True if Symbol is the value used to represent external symbols.
Definition: InstrProf.h:519
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::NamedInstrProfRecord::setCSFlagInHash
static void setCSFlagInHash(uint64_t &FuncHash)
Definition: InstrProf.h:871
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::IndexedInstrProf::Summary::Entry::Cutoff
uint64_t Cutoff
The required percentile of total execution count.
Definition: InstrProf.h:1020
llvm::IndexedInstrProf::Magic
const uint64_t Magic
Definition: InstrProf.h:970
llvm::IndexedInstrProf::HashT
HashT
Definition: InstrProf.h:957
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::NamedInstrProfRecord::hasCSFlagInHash
static bool hasCSFlagInHash(uint64_t FuncHash)
Definition: InstrProf.h:868
uint32_t
llvm::instrprof_error::eof
@ eof
Compiler.h
llvm::IndexedInstrProf::Summary::NumCutoffEntries
uint64_t NumCutoffEntries
Definition: InstrProf.h:1049
llvm::ProfileSummaryEntry
Definition: ProfileSummary.h:33
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
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::instrprof_error::hash_mismatch
@ hash_mismatch
llvm::Triple::ObjectFormatType
ObjectFormatType
Definition: Triple.h:237
llvm::InstrProfValueSiteRecord::ValueData
std::list< InstrProfValueData > ValueData
Value profiling data pairs at a given value site.
Definition: InstrProf.h:669
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:443
llvm::instrprof_category
const std::error_category & instrprof_category()
Definition: InstrProf.cpp:184
llvm::annotateValueSite
void annotateValueSite(Module &M, Instruction &Inst, const InstrProfRecord &InstrProfR, InstrProfValueKind ValueKind, uint32_t SiteIndx, uint32_t MaxMDCount=3)
Get the value profile data for value site SiteIdx from InstrProfR and annotate the instruction Inst w...
Definition: InstrProf.cpp:1000
llvm::make_error_code
std::error_code make_error_code(BitcodeError E)
Definition: BitcodeReader.h:270
llvm::InstrProfRecord::merge
void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
Definition: InstrProf.cpp:718
llvm::DoInstrProfNameCompression
cl::opt< bool > DoInstrProfNameCompression
llvm::InstrProfRecord::overlapValueProfData
void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap of value profile counts.
Definition: InstrProf.cpp:596
StringSet.h
llvm::readPGOFuncNameStrings
Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab)
NameStrings is a string composed of one of more sub-strings encoded in the format described above.
Definition: InstrProf.cpp:500
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:309
llvm::IndexedInstrProf::Summary::MaxInternalBlockCount
@ MaxInternalBlockCount
Max internal block count of the program (excluding entry blocks).
Definition: InstrProf.h:1040
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::InstrProfSymtab
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
Definition: InstrProf.h:421
llvm::StringRef::drop_front
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:652
llvm::InstrProfValueSiteRecord::overlap
void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap b/w this record and Input record.
Definition: InstrProf.cpp:565
llvm::InstrProfSymtab::getNameData
StringRef getNameData() const
Return the name section data.
Definition: InstrProf.h:532
llvm::InstrProfRecord::InstrProfRecord
InstrProfRecord(std::vector< uint64_t > Counts)
Definition: InstrProf.h:703
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::IndexedInstrProf::Summary::Summary
Summary()=delete
llvm::InstrProfRecord::InstrProfRecord
InstrProfRecord(const InstrProfRecord &RHS)
Definition: InstrProf.h:705
llvm::IndexedInstrProf::Summary
Definition: InstrProf.h:1018
llvm::SoftInstrProfErrors
Definition: InstrProf.h:349
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1590
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::OverlapStats::ProgramLevel
@ ProgramLevel
Definition: InstrProf.h:620
llvm::IndexedInstrProf::Summary::MaxBlockCount
@ MaxBlockCount
Max block count of the program.
Definition: InstrProf.h:1038
llvm::InstrProfRecord::getNumValueData
uint32_t getNumValueData(uint32_t ValueKind) const
Return the total number of ValueData for ValueKind.
Definition: InstrProf.h:883
llvm::unique
auto unique(Range &&R, Predicate P)
Definition: STLExtras.h:1802
llvm::instrprof_error::count_mismatch
@ count_mismatch
llvm::OverlapStats::Overlap
CountSumOrPercent Overlap
Definition: InstrProf.h:626
llvm::IndexedInstrProf::HashType
const HashT HashType
Definition: InstrProf.h:1001
llvm::OverlapStats::Mismatch
CountSumOrPercent Mismatch
Definition: InstrProf.h:627
llvm::getPGOFuncNameMetadataName
StringRef getPGOFuncNameMetadataName()
Definition: InstrProf.h:266
llvm::IndexedInstrProf::Version1
@ Version1
Definition: InstrProf.h:977
llvm::RawInstrProf::ProfileData
Definition: InstrProf.h:1133
llvm::InstrProfRecord::addValueData
void addValueData(uint32_t ValueKind, uint32_t Site, InstrProfValueData *VData, uint32_t N, InstrProfSymtab *SymTab)
Add ValueData for ValueKind at value Site.
Definition: InstrProf.cpp:771
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::IndexedInstrProf::Header::HashOffset
uint64_t HashOffset
Definition: InstrProf.h:1012
llvm::InstrProfSymtab::getFuncName
StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize)
Return function's PGO name from the function name's symbol address in the object file.
Definition: CoverageMappingReader.cpp:462
llvm::getInstrProfSectionName
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
Definition: InstrProf.cpp:216
llvm::InstrProfValueSiteRecord
Definition: InstrProf.h:667
llvm::InstrProfSymtab::addFuncName
Error addFuncName(StringRef FuncName)
Update the symtab by adding FuncName to the table.
Definition: InstrProf.h:482
llvm::getInstrProfValueProfMemOpFuncName
StringRef getInstrProfValueProfMemOpFuncName()
Return the name profile runtime entry point to do memop size value profiling.
Definition: InstrProf.h:79
Version
uint64_t Version
Definition: RawMemProfReader.cpp:25
llvm::CountSumOrPercent::reset
void reset()
Definition: InstrProf.h:610
llvm::InstrProfSymtab::mapAddress
void mapAddress(uint64_t Addr, uint64_t MD5Val)
Map a function address to its name's MD5 hash.
Definition: InstrProf.h:497
llvm::InstrProfRecord::sortValueData
void sortValueData()
Sort value profile data (per site) by count.
Definition: InstrProf.h:769
llvm::OverlapFuncFilters::ValueCutoff
uint64_t ValueCutoff
Definition: InstrProf.h:663
llvm::sys::IsLittleEndianHost
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:101
llvm::OverlapStats::FuncHash
uint64_t FuncHash
Definition: InstrProf.h:633
llvm::getCoverageUnusedNamesVarName
StringRef getCoverageUnusedNamesVarName()
Return the name of the internal variable recording the array of PGO name vars referenced by the cover...
Definition: InstrProf.h:115
llvm::SoftInstrProfErrors::getNumHashMismatches
unsigned getNumHashMismatches() const
Get the number of hash mismatches.
Definition: InstrProf.h:380
llvm::InstrProfSymtab::getFuncNameOrExternalSymbol
StringRef getFuncNameOrExternalSymbol(uint64_t FuncMD5Hash)
Just like getFuncName, except that it will return a non-empty StringRef if the function is external t...
Definition: InstrProf.h:566
llvm::OverlapStats::setFuncInfo
void setFuncInfo(StringRef Name, uint64_t Hash)
Definition: InstrProf.h:642
N
#define N
llvm::OverlapStats::BaseFilename
const std::string * BaseFilename
Definition: InstrProf.h:630
llvm::InstrProfRecord::reserveSites
void reserveSites(uint32_t ValueKind, uint32_t NumValueSites)
Reserve space for NumValueSites sites.
Definition: InstrProf.h:930
llvm::instrprof_error::unable_to_correlate_profile
@ unable_to_correlate_profile
llvm::getInstrProfCounterBiasVarName
StringRef getInstrProfCounterBiasVarName()
Definition: InstrProf.h:158
llvm::OverlapFuncFilters::NameFilter
const std::string NameFilter
Definition: InstrProf.h:664
llvm::SoftInstrProfErrors::~SoftInstrProfErrors
~SoftInstrProfErrors()
Definition: InstrProf.h:371
llvm::InstrProfRecord::getNumValueKinds
uint32_t getNumValueKinds() const
Return the number of value profile kinds with non-zero number of profile sites.
Definition: InstrProf.h:876
llvm::IndexedInstrProf::Header::Unused
uint64_t Unused
Definition: InstrProf.h:1010
llvm::support::endianness
endianness
Definition: Endian.h:27
llvm::OverlapStats::Base
CountSumOrPercent Base
Definition: InstrProf.h:622
llvm::NamedInstrProfRecord
Definition: InstrProf.h:856
llvm::InstrProfValueSiteRecord::sortByTargetValues
void sortByTargetValues()
Sort ValueData ascending by Value.
Definition: InstrProf.h:677
llvm::MipsISD::Ins
@ Ins
Definition: MipsISelLowering.h:157
llvm::instrprof_error::malformed
@ malformed
llvm::CountSumOrPercent::ValueCounts
double ValueCounts[IPVK_Last - IPVK_First+1]
Definition: InstrProf.h:608
llvm::getFuncNameWithoutPrefix
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName="<unknown>")
Given a PGO function name, remove the filename prefix and return the original (static) function name.
Definition: InstrProf.cpp:327
llvm::OverlapStats::accumulateCounts
Error accumulateCounts(const std::string &BaseFilename, const std::string &TestFilename, bool IsCS)
Definition: InstrProf.cpp:1230
llvm::RawInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1117
llvm::getInstrProfValueProfFuncName
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
Definition: InstrProf.h:73
llvm::StringRef::find_first_of
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition: StringRef.h:409
llvm::makeMutableArrayRef
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:532
llvm::getValueProfDataFromInst
bool getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, InstrProfValueData ValueData[], uint32_t &ActualNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst which is annotated with value profile meta data.
Definition: InstrProf.cpp:1045
llvm::IndexedInstrProf::Summary::TotalNumBlocks
@ TotalNumBlocks
Total number of instrumented blocks/edges.
Definition: InstrProf.h:1032
llvm::getInstrProfDataVarPrefix
StringRef getInstrProfDataVarPrefix()
Return the name prefix of variables containing per-function control data.
Definition: InstrProf.h:87
llvm::RawInstrProf::Header
Definition: InstrProf.h:1142
raw_ostream.h
error_category
static ManagedStatic< _object_error_category > error_category
Definition: Error.cpp:76
Endian.h
llvm::IndexedInstrProf::Summary::NumSummaryFields
uint64_t NumSummaryFields
Definition: InstrProf.h:1047
llvm::IndexedInstrProf::Summary::Entry::MinBlockCount
uint64_t MinBlockCount
The minimum execution count for this percentile.
Definition: InstrProf.h:1022
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:968
llvm::DebugInfoCorrelate
cl::opt< bool > DebugInfoCorrelate("debug-info-correlate", cl::ZeroOrMore, cl::desc("Use debug info to correlate profiles."), cl::init(false))
Definition: PGOInstrumentation.cpp:295
llvm::IndexedInstrProf::Version2
@ Version2
Definition: InstrProf.h:982
llvm::getInstrProfRegFuncName
StringRef getInstrProfRegFuncName()
Return the name of the runtime interface that registers per-function control data for one instrumente...
Definition: InstrProf.h:130
llvm::OverlapStats::addOneMismatch
void addOneMismatch(const CountSumOrPercent &MismatchFunc)
Definition: InstrProf.cpp:1255
llvm::InstrProfRecord::Counts
std::vector< uint64_t > Counts
Definition: InstrProf.h:700
llvm::IndexedInstrProf::Summary::getSummaryDataBase
const uint64_t * getSummaryDataBase() const
Definition: InstrProf.h:1061
llvm::instrprof_error::counter_overflow
@ counter_overflow
llvm::support::big
@ big
Definition: Endian.h:27
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::IndexedInstrProf::Version3
@ Version3
Definition: InstrProf.h:985
llvm::OverlapStats::Test
CountSumOrPercent Test
Definition: InstrProf.h:624
llvm::instrprof_error::missing_debug_info_for_correlation
@ missing_debug_info_for_correlation
llvm::instrprof_error::unsupported_debug_format
@ unsupported_debug_format
llvm::getPGOFuncNameMetadata
MDNode * getPGOFuncNameMetadata(const Function &F)
Return the PGOFuncName meta data associated with a function.
Definition: InstrProf.cpp:1101
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
llvm::InstrProfRecord::scale
void scale(uint64_t N, uint64_t D, function_ref< void(instrprof_error)> Warn)
Scale up profile counts (including value profile data) by a factor of (N / D).
Definition: InstrProf.cpp:746
llvm::InstrProfValueSiteRecord::InstrProfValueSiteRecord
InstrProfValueSiteRecord(InputIterator F, InputIterator L)
Definition: InstrProf.h:673