LLVM 22.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"
20#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/STLExtras.h"
23#include "llvm/ADT/StringRef.h"
24#include "llvm/ADT/StringSet.h"
25#include "llvm/IR/GlobalValue.h"
32#include "llvm/Support/Error.h"
34#include "llvm/Support/MD5.h"
39#include <algorithm>
40#include <cassert>
41#include <cstddef>
42#include <cstdint>
43#include <cstring>
44#include <list>
45#include <memory>
46#include <string>
47#include <system_error>
48#include <utility>
49#include <vector>
50
51namespace llvm {
52
53class Function;
54class GlobalVariable;
55struct InstrProfRecord;
56class InstrProfSymtab;
57class Instruction;
58class MDNode;
59class Module;
60
61// A struct to define how the data stream should be patched. For Indexed
62// profiling, only uint64_t data type is needed.
63struct PatchItem {
64 uint64_t Pos; // Where to patch.
65 ArrayRef<uint64_t> D; // An array of source data.
66};
67
68// A wrapper class to abstract writer stream with support of bytes
69// back patching.
71public:
74
75 [[nodiscard]] LLVM_ABI uint64_t tell() const;
76 LLVM_ABI void write(uint64_t V);
79
80 // \c patch can only be called when all data is written and flushed.
81 // For raw_string_ostream, the patch is done on the target string
82 // directly and it won't be reflected in the stream's internal buffer.
84
85 // If \c OS is an instance of \c raw_fd_ostream, this field will be
86 // true. Otherwise, \c OS will be an raw_string_ostream.
90};
91
93#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) Kind,
95};
96
97/// Return the max count value. We reserver a few large values for special use.
99 return std::numeric_limits<uint64_t>::max() - 2;
100}
101
102/// Return the name of the profile section corresponding to \p IPSK.
103///
104/// The name of the section depends on the object format type \p OF. If
105/// \p AddSegmentInfo is true, a segment prefix and additional linker hints may
106/// be added to the section name (this is the default).
109 bool AddSegmentInfo = true);
110
111/// Return the name profile runtime entry point to do value profiling
112/// for a given site.
114 return INSTR_PROF_VALUE_PROF_FUNC_STR;
115}
116
117/// Return the name profile runtime entry point to do memop size value
118/// profiling.
120 return INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR;
121}
122
123/// Return the name prefix of variables containing instrumented function names.
124inline StringRef getInstrProfNameVarPrefix() { return "__profn_"; }
125
126/// Return the name prefix of variables containing virtual table profile data.
127inline StringRef getInstrProfVTableVarPrefix() { return "__profvt_"; }
128
129/// Return the name prefix of variables containing per-function control data.
130inline StringRef getInstrProfDataVarPrefix() { return "__profd_"; }
131
132/// Return the name prefix of profile counter variables.
133inline StringRef getInstrProfCountersVarPrefix() { return "__profc_"; }
134
135/// Return the name prefix of profile bitmap variables.
136inline StringRef getInstrProfBitmapVarPrefix() { return "__profbm_"; }
137
138/// Return the name prefix of value profile variables.
139inline StringRef getInstrProfValuesVarPrefix() { return "__profvp_"; }
140
141/// Return the name of value profile node array variables:
142inline StringRef getInstrProfVNodesVarName() { return "__llvm_prf_vnodes"; }
143
144/// Return the name of the variable holding the strings (possibly compressed)
145/// of all function's PGO names.
146inline StringRef getInstrProfNamesVarName() { return "__llvm_prf_nm"; }
147
148inline StringRef getInstrProfVTableNamesVarName() { return "__llvm_prf_vnm"; }
149
150/// Return the name of a covarage mapping variable (internal linkage)
151/// for each instrumented source module. Such variables are allocated
152/// in the __llvm_covmap section.
154 return "__llvm_coverage_mapping";
155}
156
157/// Return the name of the internal variable recording the array
158/// of PGO name vars referenced by the coverage mapping. The owning
159/// functions of those names are not emitted by FE (e.g, unused inline
160/// functions.)
162 return "__llvm_coverage_names";
163}
164
165/// Return the name of function that registers all the per-function control
166/// data at program startup time by calling __llvm_register_function. This
167/// function has internal linkage and is called by __llvm_profile_init
168/// runtime method. This function is not generated for these platforms:
169/// Darwin, Linux, and FreeBSD.
171 return "__llvm_profile_register_functions";
172}
173
174/// Return the name of the runtime interface that registers per-function control
175/// data for one instrumented function.
177 return "__llvm_profile_register_function";
178}
179
180/// Return the name of the runtime interface that registers the PGO name
181/// strings.
183 return "__llvm_profile_register_names_function";
184}
185
186/// Return the name of the runtime initialization method that is generated by
187/// the compiler. The function calls __llvm_profile_register_functions and
188/// __llvm_profile_override_default_filename functions if needed. This function
189/// has internal linkage and invoked at startup time via init_array.
190inline StringRef getInstrProfInitFuncName() { return "__llvm_profile_init"; }
191
192/// Return the name of the hook variable defined in profile runtime library.
193/// A reference to the variable causes the linker to link in the runtime
194/// initialization module (which defines the hook variable).
196 return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_RUNTIME_VAR);
197}
198
199/// Return the name of the compiler generated function that references the
200/// runtime hook variable. The function is a weak global.
202 return "__llvm_profile_runtime_user";
203}
204
206 return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_COUNTER_BIAS_VAR);
207}
208
210 return INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_BITMAP_BIAS_VAR);
211}
212
213/// Return the marker used to separate PGO names during serialization.
214inline StringRef getInstrProfNameSeparator() { return "\01"; }
215
216/// Determines whether module targets a GPU eligable for PGO
217/// instrumentation
218LLVM_ABI bool isGPUProfTarget(const Module &M);
219
220/// Please use getIRPGOFuncName for LLVM IR instrumentation. This function is
221/// for front-end (Clang, etc) instrumentation.
222/// Return the modified name for function \c F suitable to be
223/// used the key for profile lookup. Variable \c InLTO indicates if this
224/// is called in LTO optimization passes.
225LLVM_ABI std::string
226getPGOFuncName(const Function &F, bool InLTO = false,
227 uint64_t Version = INSTR_PROF_INDEX_VERSION);
228
229/// Return the modified name for a function suitable to be
230/// used the key for profile lookup. The function's original
231/// name is \c RawFuncName and has linkage of type \c Linkage.
232/// The function is defined in module \c FileName.
233LLVM_ABI std::string
235 StringRef FileName, uint64_t Version = INSTR_PROF_INDEX_VERSION);
236
237/// \return the modified name for function \c F suitable to be
238/// used as the key for IRPGO profile lookup. \c InLTO indicates if this is
239/// called from LTO optimization passes.
240LLVM_ABI std::string getIRPGOFuncName(const Function &F, bool InLTO = false);
241
242/// \return the filename and the function name parsed from the output of
243/// \c getIRPGOFuncName()
244LLVM_ABI std::pair<StringRef, StringRef>
245getParsedIRPGOName(StringRef IRPGOName);
246
247/// Return the name of the global variable used to store a function
248/// name in PGO instrumentation. \c FuncName is the IRPGO function name
249/// (returned by \c getIRPGOFuncName) for LLVM IR instrumentation and PGO
250/// function name (returned by \c getPGOFuncName) for front-end instrumentation.
251LLVM_ABI std::string getPGOFuncNameVarName(StringRef FuncName,
253
254/// Create and return the global variable for function name used in PGO
255/// instrumentation. \c FuncName is the IRPGO function name (returned by
256/// \c getIRPGOFuncName) for LLVM IR instrumentation and PGO function name
257/// (returned by \c getPGOFuncName) for front-end instrumentation.
258LLVM_ABI GlobalVariable *createPGOFuncNameVar(Function &F,
259 StringRef PGOFuncName);
260
261/// Create and return the global variable for function name used in PGO
262/// instrumentation. \c FuncName is the IRPGO function name (returned by
263/// \c getIRPGOFuncName) for LLVM IR instrumentation and PGO function name
264/// (returned by \c getPGOFuncName) for front-end instrumentation.
265LLVM_ABI GlobalVariable *createPGOFuncNameVar(Module &M,
267 StringRef PGOFuncName);
268
269/// Return the initializer in string of the PGO name var \c NameVar.
270LLVM_ABI StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar);
271
272/// Given a PGO function name, remove the filename prefix and return
273/// the original (static) function name.
274LLVM_ABI StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName,
275 StringRef FileName = "<unknown>");
276
277/// Given a vector of strings (names of global objects like functions or,
278/// virtual tables) \c NameStrs, the method generates a combined string \c
279/// Result that is ready to be serialized. The \c Result string is comprised of
280/// three fields: The first field is the length of the uncompressed strings, and
281/// the the second field is the length of the zlib-compressed string. Both
282/// fields are encoded in ULEB128. If \c doCompress is false, the
283/// third field is the uncompressed strings; otherwise it is the
284/// compressed string. When the string compression is off, the
285/// second field will have value zero.
286LLVM_ABI Error collectGlobalObjectNameStrings(ArrayRef<std::string> NameStrs,
287 bool doCompression,
288 std::string &Result);
289
290/// Produce \c Result string with the same format described above. The input
291/// is vector of PGO function name variables that are referenced.
292/// The global variable element in 'NameVars' is a string containing the pgo
293/// name of a function. See `createPGOFuncNameVar` that creates these global
294/// variables.
295LLVM_ABI Error collectPGOFuncNameStrings(ArrayRef<GlobalVariable *> NameVars,
296 std::string &Result,
297 bool doCompression = true);
298
299LLVM_ABI Error collectVTableStrings(ArrayRef<GlobalVariable *> VTables,
300 std::string &Result, bool doCompression);
301
302/// Check if INSTR_PROF_RAW_VERSION_VAR is defined. This global is only being
303/// set in IR PGO compilation.
304LLVM_ABI bool isIRPGOFlagSet(const Module *M);
305
306/// Check if we can safely rename this Comdat function. Instances of the same
307/// comdat function may have different control flows thus can not share the
308/// same counter variable.
309LLVM_ABI bool canRenameComdatFunc(const Function &F,
310 bool CheckAddressTaken = false);
311
313#define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value,
315};
316
317/// Get the value profile data for value site \p SiteIdx from \p InstrProfR
318/// and annotate the instruction \p Inst with the value profile meta data.
319/// Annotate up to \p MaxMDCount (default 3) number of records per value site.
320LLVM_ABI void annotateValueSite(Module &M, Instruction &Inst,
321 const InstrProfRecord &InstrProfR,
322 InstrProfValueKind ValueKind, uint32_t SiteIndx,
323 uint32_t MaxMDCount = 3);
324
325/// Same as the above interface but using an ArrayRef, as well as \p Sum.
326/// This function will not annotate !prof metadata on the instruction if the
327/// referenced array is empty.
328LLVM_ABI void annotateValueSite(Module &M, Instruction &Inst,
329 ArrayRef<InstrProfValueData> VDs, uint64_t Sum,
330 InstrProfValueKind ValueKind,
331 uint32_t MaxMDCount);
332
333// TODO: Unify metadata name 'PGOFuncName' and 'PGOName', by supporting read
334// of this metadata for backward compatibility and generating 'PGOName' only.
335/// Extract the value profile data from \p Inst and returns them if \p Inst is
336/// annotated with value profile data. Returns an empty vector otherwise.
337LLVM_ABI SmallVector<InstrProfValueData, 4>
338getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
339 uint32_t MaxNumValueData, uint64_t &TotalC,
340 bool GetNoICPValue = false);
341
342inline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; }
343
344inline StringRef getPGONameMetadataName() { return "PGOName"; }
345
346/// Return the PGOFuncName meta data associated with a function.
347LLVM_ABI MDNode *getPGOFuncNameMetadata(const Function &F);
348
349LLVM_ABI std::string getPGOName(const GlobalVariable &V, bool InLTO = false);
350
351/// Create the PGOFuncName meta data if PGOFuncName is different from
352/// function's raw name. This should only apply to internal linkage functions
353/// declared by users only.
354/// TODO: Update all callers to 'createPGONameMetadata' and deprecate this
355/// function.
356LLVM_ABI void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName);
357
358/// Create the PGOName metadata if a global object's PGO name is different from
359/// its mangled name. This should apply to local-linkage global objects only.
360LLVM_ABI void createPGONameMetadata(GlobalObject &GO, StringRef PGOName);
361
362/// Check if we can use Comdat for profile variables. This will eliminate
363/// the duplicated profile variables for Comdat functions.
364LLVM_ABI bool needsComdatForCounter(const GlobalObject &GV, const Module &M);
365
366/// \c NameStrings is a string composed of one or more possibly encoded
367/// sub-strings. The substrings are separated by `\01` (returned by
368/// InstrProf.h:getInstrProfNameSeparator). This method decodes the string and
369/// calls `NameCallback` for each substring.
371 StringRef NameStrings, std::function<Error(StringRef)> NameCallback);
372
373/// An enum describing the attributes of an instrumented profile.
374enum class InstrProfKind {
375 Unknown = 0x0,
376 // A frontend clang profile, incompatible with other attrs.
378 // An IR-level profile (default when -fprofile-generate is used).
379 IRInstrumentation = 0x2,
380 // A profile with entry basic block instrumentation.
382 // A context sensitive IR-level profile.
383 ContextSensitive = 0x8,
384 // Use single byte probes for coverage.
385 SingleByteCoverage = 0x10,
386 // Only instrument the function entry basic block.
387 FunctionEntryOnly = 0x20,
388 // A memory profile collected using -fprofile=memory.
389 MemProf = 0x40,
390 // A temporal profile.
391 TemporalProfile = 0x80,
392 // A profile with loop entry basic blocks instrumentation.
395};
396
397LLVM_ABI const std::error_category &instrprof_category();
398
399enum class instrprof_error {
400 success = 0,
401 eof,
403 bad_magic,
407 too_large,
408 truncated,
409 malformed,
426};
427
428/// An ordered list of functions identified by their NameRef found in
429/// INSTR_PROF_DATA
431 std::vector<uint64_t> FunctionNameRefs;
433 TemporalProfTraceTy(std::initializer_list<uint64_t> Trace = {},
434 uint64_t Weight = 1)
436
437 /// Use a set of temporal profile traces to create a list of balanced
438 /// partitioning function nodes used by BalancedPartitioning to generate a
439 /// function order that reduces page faults during startup
440 LLVM_ABI static void
441 createBPFunctionNodes(ArrayRef<TemporalProfTraceTy> Traces,
442 std::vector<BPFunctionNode> &Nodes,
443 bool RemoveOutlierUNs = true);
444};
445
446inline std::error_code make_error_code(instrprof_error E) {
447 return std::error_code(static_cast<int>(E), instrprof_category());
448}
449
450class LLVM_ABI InstrProfError : public ErrorInfo<InstrProfError> {
451public:
453 : Err(Err), Msg(ErrStr.str()) {
454 assert(Err != instrprof_error::success && "Not an error");
455 }
456
457 std::string message() const override;
458
459 void log(raw_ostream &OS) const override { OS << message(); }
460
461 std::error_code convertToErrorCode() const override {
462 return make_error_code(Err);
463 }
464
465 instrprof_error get() const { return Err; }
466 const std::string &getMessage() const { return Msg; }
467
468 /// Consume an Error and return the raw enum value contained within it, and
469 /// the optional error message. The Error must either be a success value, or
470 /// contain a single InstrProfError.
471 static std::pair<instrprof_error, std::string> take(Error E) {
472 auto Err = instrprof_error::success;
473 std::string Msg = "";
474 handleAllErrors(std::move(E), [&Err, &Msg](const InstrProfError &IPE) {
475 assert(Err == instrprof_error::success && "Multiple errors encountered");
476 Err = IPE.get();
477 Msg = IPE.getMessage();
478 });
479 return {Err, Msg};
480 }
481
482 static char ID;
483
484private:
485 instrprof_error Err;
486 std::string Msg;
487};
488
489namespace object {
490
491class SectionRef;
492
493} // end namespace object
494
495namespace IndexedInstrProf {
496
498
499} // end namespace IndexedInstrProf
500
501/// A symbol table used for function [IR]PGO name look-up with keys
502/// (such as pointers, md5hash values) to the function. A function's
503/// [IR]PGO name or name's md5hash are used in retrieving the profile
504/// data of the function. See \c getIRPGOFuncName() and \c getPGOFuncName
505/// methods for details how [IR]PGO name is formed.
507public:
508 using AddrHashMap = std::vector<std::pair<uint64_t, uint64_t>>;
509
510 // Returns the canonical name of the given PGOName. In a canonical name, all
511 // suffixes that begins with "." except ".__uniq." are stripped.
512 // FIXME: Unify this with `FunctionSamples::getCanonicalFnName`.
514
515private:
516 using AddrIntervalMap =
518 StringRef Data;
519 uint64_t Address = 0;
520 // Unique name strings. Used to ensure entries in MD5NameMap (a vector that's
521 // going to be sorted) has unique MD5 keys in the first place.
522 StringSet<> NameTab;
523 // Records the unique virtual table names. This is used by InstrProfWriter to
524 // write out an on-disk chained hash table of virtual table names.
525 // InstrProfWriter stores per function profile data (keyed by function names)
526 // so it doesn't use a StringSet for function names.
527 StringSet<> VTableNames;
528 // A map from MD5 keys to function name strings.
529 mutable std::vector<std::pair<uint64_t, StringRef>> MD5NameMap;
530 // A map from MD5 keys to function define. We only populate this map
531 // when build the Symtab from a Module.
532 mutable std::vector<std::pair<uint64_t, Function *>> MD5FuncMap;
533 // A map from MD5 to the global variable. This map is only populated when
534 // building the symtab from a module. Use separate container instances for
535 // `MD5FuncMap` and `MD5VTableMap`.
536 // TODO: Unify the container type and the lambda function 'mapName' inside
537 // add{Func,VTable}WithName.
538 mutable DenseMap<uint64_t, GlobalVariable *> MD5VTableMap;
539 // A map from function runtime address to function name MD5 hash.
540 // This map is only populated and used by raw instr profile reader.
541 mutable AddrHashMap AddrToMD5Map;
542
543 AddrIntervalMap::Allocator VTableAddrMapAllocator;
544 // This map is only populated and used by raw instr profile reader.
545 AddrIntervalMap VTableAddrMap;
546
547 // "dirty" flag for the rest of the mutable state. lookup APIs (like
548 // getFunction) need the mutable state to be sorted.
549 mutable bool Sorted = false;
550
551 static StringRef getExternalSymbol() { return "** External Symbol **"; }
552
553 // Add the function into the symbol table, by creating the following
554 // map entries:
555 // name-set = {PGOFuncName} union {getCanonicalName(PGOFuncName)}
556 // - In MD5NameMap: <MD5Hash(name), name> for name in name-set
557 // - In MD5FuncMap: <MD5Hash(name), &F> for name in name-set
558 // The canonical name is only added if \c AddCanonical is true.
559 Error addFuncWithName(Function &F, StringRef PGOFuncName, bool AddCanonical);
560
561 // Add the vtable into the symbol table, by creating the following
562 // map entries:
563 // name-set = {PGOName} union {getCanonicalName(PGOName)}
564 // - In MD5NameMap: <MD5Hash(name), name> for name in name-set
565 // - In MD5VTableMap: <MD5Hash(name), name> for name in name-set
566 Error addVTableWithName(GlobalVariable &V, StringRef PGOVTableName);
567
568 // If the symtab is created by a series of calls to \c addFuncName, \c
569 // finalizeSymtab needs to be called before looking up function names.
570 // This is required because the underlying map is a vector (for space
571 // efficiency) which needs to be sorted. The API is `const` because it's part
572 // of the implementation detail of `const` APIs that need to first ensure this
573 // property of ordering on the other mutable state.
574 inline void finalizeSymtab() const;
575
576public:
577 InstrProfSymtab() : VTableAddrMap(VTableAddrMapAllocator) {}
578
579 // Not copyable or movable.
580 // Consider std::unique_ptr for move.
585
586 /// Create InstrProfSymtab from an object file section which
587 /// contains function PGO names. When section may contain raw
588 /// string data or string data in compressed form. This method
589 /// only initialize the symtab with reference to the data and
590 /// the section base address. The decompression will be delayed
591 /// until before it is used. See also \c create(StringRef) method.
593
594 /// \c NameStrings is a string composed of one of more sub-strings
595 /// encoded in the format described in \c collectPGOFuncNameStrings.
596 /// This method is a wrapper to \c readAndDecodeStrings method.
597 LLVM_ABI Error create(StringRef NameStrings);
598
599 /// Initialize symtab states with function names and vtable names. \c
600 /// FuncNameStrings is a string composed of one or more encoded function name
601 /// strings, and \c VTableNameStrings composes of one or more encoded vtable
602 /// names. This interface is solely used by raw profile reader.
603 LLVM_ABI Error create(StringRef FuncNameStrings, StringRef VTableNameStrings);
604
605 /// Initialize 'this' with the set of vtable names encoded in
606 /// \c CompressedVTableNames.
608 initVTableNamesFromCompressedStrings(StringRef CompressedVTableNames);
609
610 /// This interface is used by reader of CoverageMapping test
611 /// format.
612 inline Error create(StringRef D, uint64_t BaseAddr);
613
614 /// A wrapper interface to populate the PGO symtab with functions
615 /// decls from module \c M. This interface is used by transformation
616 /// passes such as indirect function call promotion. Variable \c InLTO
617 /// indicates if this is called from LTO optimization passes.
618 /// A canonical name, removing non-__uniq suffixes, is added if
619 /// \c AddCanonical is true.
620 LLVM_ABI Error create(Module &M, bool InLTO = false,
621 bool AddCanonical = true);
622
623 /// Create InstrProfSymtab from a set of names iteratable from
624 /// \p IterRange. This interface is used by IndexedProfReader.
625 template <typename NameIterRange>
626 Error create(const NameIterRange &IterRange);
627
628 /// Create InstrProfSymtab from a set of function names and vtable
629 /// names iteratable from \p IterRange. This interface is used by
630 /// IndexedProfReader.
631 template <typename FuncNameIterRange, typename VTableNameIterRange>
632 Error create(const FuncNameIterRange &FuncIterRange,
633 const VTableNameIterRange &VTableIterRange);
634
635 // Map the MD5 of the symbol name to the name.
637 if (SymbolName.empty())
638 return make_error<InstrProfError>(instrprof_error::malformed,
639 "symbol name is empty");
640
641 // Insert into NameTab so that MD5NameMap (a vector that will be sorted)
642 // won't have duplicated entries in the first place.
643 auto Ins = NameTab.insert(SymbolName);
644 if (Ins.second) {
645 MD5NameMap.push_back(std::make_pair(
646 IndexedInstrProf::ComputeHash(SymbolName), Ins.first->getKey()));
647 Sorted = false;
648 }
649 return Error::success();
650 }
651
652 /// The method name is kept since there are many callers.
653 /// It just forwards to 'addSymbolName'.
654 Error addFuncName(StringRef FuncName) { return addSymbolName(FuncName); }
655
656 /// Adds VTableName as a known symbol, and inserts it to a map that
657 /// tracks all vtable names.
659 if (Error E = addSymbolName(VTableName))
660 return E;
661
662 // Record VTableName. InstrProfWriter uses this set. The comment around
663 // class member explains why.
664 VTableNames.insert(VTableName);
665 return Error::success();
666 }
667
668 const std::vector<std::pair<uint64_t, Function *>> &getIDToNameMap() const {
669 return MD5FuncMap;
670 }
671
672 const StringSet<> &getVTableNames() const { return VTableNames; }
673
674 /// Map a function address to its name's MD5 hash. This interface
675 /// is only used by the raw profiler reader.
677 AddrToMD5Map.push_back(std::make_pair(Addr, MD5Val));
678 }
679
680 /// Map the address range (i.e., [start_address, end_address)) of a variable
681 /// to its names' MD5 hash. This interface is only used by the raw profile
682 /// reader.
683 void mapVTableAddress(uint64_t StartAddr, uint64_t EndAddr, uint64_t MD5Val) {
684 VTableAddrMap.insert(StartAddr, EndAddr, MD5Val);
685 }
686
687 /// Return a function's hash, or 0, if the function isn't in this SymTab.
689
690 /// Return a vtable's hash, or 0 if the vtable doesn't exist in this SymTab.
692
693 /// Return function's PGO name from the function name's symbol
694 /// address in the object file. If an error occurs, return
695 /// an empty string.
696 LLVM_ABI StringRef getFuncName(uint64_t FuncNameAddress,
697 size_t NameSize) const;
698
699 /// Return name of functions or global variables from the name's md5 hash
700 /// value. If not found, return an empty string.
701 inline StringRef getFuncOrVarName(uint64_t ValMD5Hash) const;
702
703 /// Just like getFuncOrVarName, except that it will return literal string
704 /// 'External Symbol' if the function or global variable is external to
705 /// this symbol table.
706 inline StringRef getFuncOrVarNameIfDefined(uint64_t ValMD5Hash) const;
707
708 /// True if Symbol is the value used to represent external symbols.
709 static bool isExternalSymbol(const StringRef &Symbol) {
710 return Symbol == InstrProfSymtab::getExternalSymbol();
711 }
712
713 /// Return function from the name's md5 hash. Return nullptr if not found.
714 inline Function *getFunction(uint64_t FuncMD5Hash) const;
715
716 /// Return the global variable corresponding to md5 hash. Return nullptr if
717 /// not found.
719
720 /// Return the name section data.
721 inline StringRef getNameData() const { return Data; }
722
723 /// Dump the symbols in this table.
724 LLVM_ABI void dumpNames(raw_ostream &OS) const;
725};
726
728 Data = D;
729 Address = BaseAddr;
730 return Error::success();
731}
732
733template <typename NameIterRange>
734Error InstrProfSymtab::create(const NameIterRange &IterRange) {
735 for (auto Name : IterRange)
736 if (Error E = addFuncName(Name))
737 return E;
738
739 finalizeSymtab();
740 return Error::success();
741}
742
743template <typename FuncNameIterRange, typename VTableNameIterRange>
744Error InstrProfSymtab::create(const FuncNameIterRange &FuncIterRange,
745 const VTableNameIterRange &VTableIterRange) {
746 // Iterate elements by StringRef rather than by const reference.
747 // StringRef is small enough, so the loop is efficient whether
748 // element in the range is std::string or StringRef.
749 for (StringRef Name : FuncIterRange)
750 if (Error E = addFuncName(Name))
751 return E;
752
753 for (StringRef VTableName : VTableIterRange)
754 if (Error E = addVTableName(VTableName))
755 return E;
756
757 finalizeSymtab();
758 return Error::success();
759}
760
761void InstrProfSymtab::finalizeSymtab() const {
762 if (Sorted)
763 return;
764 llvm::sort(MD5NameMap, less_first());
765 llvm::sort(MD5FuncMap, less_first());
766 llvm::sort(AddrToMD5Map, less_first());
767 AddrToMD5Map.erase(llvm::unique(AddrToMD5Map), AddrToMD5Map.end());
768 Sorted = true;
769}
770
773 if (Ret.empty())
774 return InstrProfSymtab::getExternalSymbol();
775 return Ret;
776}
777
779 finalizeSymtab();
780 auto Result = llvm::lower_bound(MD5NameMap, MD5Hash,
781 [](const std::pair<uint64_t, StringRef> &LHS,
782 uint64_t RHS) { return LHS.first < RHS; });
783 if (Result != MD5NameMap.end() && Result->first == MD5Hash)
784 return Result->second;
785 return StringRef();
786}
787
789 finalizeSymtab();
790 auto Result = llvm::lower_bound(MD5FuncMap, FuncMD5Hash,
791 [](const std::pair<uint64_t, Function *> &LHS,
792 uint64_t RHS) { return LHS.first < RHS; });
793 if (Result != MD5FuncMap.end() && Result->first == FuncMD5Hash)
794 return Result->second;
795 return nullptr;
796}
797
799 return MD5VTableMap.lookup(MD5Hash);
800}
801
802// To store the sums of profile count values, or the percentage of
803// the sums of the total count values.
806 double CountSum = 0.0f;
807 std::array<double, IPVK_Last - IPVK_First + 1> ValueCounts = {};
808 CountSumOrPercent() = default;
809 void reset() {
810 NumEntries = 0;
811 CountSum = 0.0f;
812 ValueCounts.fill(0.0f);
813 }
814};
815
816// Function level or program level overlap information.
819 // Sum of the total count values for the base profile.
821 // Sum of the total count values for the test profile.
823 // Overlap lap score. Should be in range of [0.0f to 1.0f].
828 const std::string *BaseFilename = nullptr;
829 const std::string *TestFilename = nullptr;
832 bool Valid = false;
833
835
836 LLVM_ABI void dump(raw_fd_ostream &OS) const;
837
839 FuncName = Name;
840 FuncHash = Hash;
841 }
842
843 LLVM_ABI Error accumulateCounts(const std::string &BaseFilename,
844 const std::string &TestFilename, bool IsCS);
845 LLVM_ABI void addOneMismatch(const CountSumOrPercent &MismatchFunc);
846 LLVM_ABI void addOneUnique(const CountSumOrPercent &UniqueFunc);
847
848 static inline double score(uint64_t Val1, uint64_t Val2, double Sum1,
849 double Sum2) {
850 if (Sum1 < 1.0f || Sum2 < 1.0f)
851 return 0.0f;
852 return std::min(Val1 / Sum1, Val2 / Sum2);
853 }
854};
855
856// This is used to filter the functions whose overlap information
857// to be output.
860 const std::string NameFilter;
861};
862
864 /// Value profiling data pairs at a given value site.
865 std::vector<InstrProfValueData> ValueData;
866
868 InstrProfValueSiteRecord(std::vector<InstrProfValueData> &&VD)
869 : ValueData(VD) {}
870
871 /// Sort ValueData ascending by Value
874 [](const InstrProfValueData &L, const InstrProfValueData &R) {
875 return L.Value < R.Value;
876 });
877 }
878 /// Sort ValueData Descending by Count
879 inline void sortByCount();
880
881 /// Merge data from another InstrProfValueSiteRecord
882 /// Optionally scale merged counts by \p Weight.
884 function_ref<void(instrprof_error)> Warn);
885 /// Scale up value profile data counts by N (Numerator) / D (Denominator).
887 function_ref<void(instrprof_error)> Warn);
888
889 /// Compute the overlap b/w this record and Input record.
890 LLVM_ABI void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind,
891 OverlapStats &Overlap, OverlapStats &FuncLevelOverlap);
892};
893
894/// Profiling information for a single function.
896 std::vector<uint64_t> Counts;
897 std::vector<uint8_t> BitmapBytes;
898
899 InstrProfRecord() = default;
900 InstrProfRecord(std::vector<uint64_t> Counts) : Counts(std::move(Counts)) {}
901 InstrProfRecord(std::vector<uint64_t> Counts,
902 std::vector<uint8_t> BitmapBytes)
907 ValueData(RHS.ValueData
908 ? std::make_unique<ValueProfData>(*RHS.ValueData)
909 : nullptr) {}
912 Counts = RHS.Counts;
913 BitmapBytes = RHS.BitmapBytes;
914 if (!RHS.ValueData) {
915 ValueData = nullptr;
916 return *this;
917 }
918 if (!ValueData)
919 ValueData = std::make_unique<ValueProfData>(*RHS.ValueData);
920 else
921 *ValueData = *RHS.ValueData;
922 return *this;
923 }
924
925 /// Return the number of value profile kinds with non-zero number
926 /// of profile sites.
927 inline uint32_t getNumValueKinds() const;
928 /// Return the number of instrumented sites for ValueKind.
929 inline uint32_t getNumValueSites(uint32_t ValueKind) const;
930
931 /// Return the total number of ValueData for ValueKind.
932 inline uint32_t getNumValueData(uint32_t ValueKind) const;
933
934 /// Return the array of profiled values at \p Site.
936 uint32_t Site) const;
937
938 /// Reserve space for NumValueSites sites.
939 inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
940
941 /// Add ValueData for ValueKind at value Site. We do not support adding sites
942 /// out of order. Site must go up from 0 one by one.
943 LLVM_ABI void addValueData(uint32_t ValueKind, uint32_t Site,
945 InstrProfSymtab *SymTab);
946
947 /// Merge the counts in \p Other into this one.
948 /// Optionally scale merged counts by \p Weight.
950 function_ref<void(instrprof_error)> Warn);
951
952 /// Scale up profile counts (including value profile data) by
953 /// a factor of (N / D).
955 function_ref<void(instrprof_error)> Warn);
956
957 /// Sort value profile data (per site) by count.
959 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
960 for (auto &SR : getValueSitesForKind(Kind))
961 SR.sortByCount();
962 }
963
964 /// Clear value data entries and edge counters.
965 void Clear() {
966 Counts.clear();
968 }
969
970 /// Clear value data entries
971 void clearValueData() { ValueData = nullptr; }
972
973 /// Compute the sums of all counts and store in Sum.
975
976 /// Compute the overlap b/w this IntrprofRecord and Other.
978 OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff);
979
980 /// Compute the overlap of value profile counts.
982 OverlapStats &Overlap,
983 OverlapStats &FuncLevelOverlap);
984
989 };
993 };
995 uint64_t FirstCount = Counts[0];
996 if (FirstCount == (uint64_t)HotFunctionVal)
997 return PseudoHot;
998 if (FirstCount == (uint64_t)WarmFunctionVal)
999 return PseudoWarm;
1000 return NotPseudo;
1001 }
1003 if (Kind == PseudoHot)
1005 else if (Kind == PseudoWarm)
1007 }
1008
1009private:
1010 using ValueProfData = std::array<std::vector<InstrProfValueSiteRecord>,
1011 IPVK_Last - IPVK_First + 1>;
1012 std::unique_ptr<ValueProfData> ValueData;
1013
1015 getValueSitesForKind(uint32_t ValueKind) {
1016 // Cast to /add/ const (should be an implicit_cast, ideally, if that's ever
1017 // implemented in LLVM) to call the const overload of this function, then
1018 // cast away the constness from the result.
1019 auto AR = const_cast<const InstrProfRecord *>(this)->getValueSitesForKind(
1020 ValueKind);
1021 return MutableArrayRef(
1022 const_cast<InstrProfValueSiteRecord *>(AR.data()), AR.size());
1023 }
1024 ArrayRef<InstrProfValueSiteRecord>
1025 getValueSitesForKind(uint32_t ValueKind) const {
1026 if (!ValueData)
1027 return {};
1028 assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
1029 "Unknown value kind!");
1030 return (*ValueData)[ValueKind - IPVK_First];
1031 }
1032
1033 std::vector<InstrProfValueSiteRecord> &
1034 getOrCreateValueSitesForKind(uint32_t ValueKind) {
1035 if (!ValueData)
1036 ValueData = std::make_unique<ValueProfData>();
1037 assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
1038 "Unknown value kind!");
1039 return (*ValueData)[ValueKind - IPVK_First];
1040 }
1041
1042 // Map indirect call target name hash to name string.
1043 uint64_t remapValue(uint64_t Value, uint32_t ValueKind,
1044 InstrProfSymtab *SymTab);
1045
1046 // Merge Value Profile data from Src record to this record for ValueKind.
1047 // Scale merged value counts by \p Weight.
1048 void mergeValueProfData(uint32_t ValkeKind, InstrProfRecord &Src,
1049 uint64_t Weight,
1050 function_ref<void(instrprof_error)> Warn);
1051
1052 // Scale up value profile data count by N (Numerator) / D (Denominator).
1053 void scaleValueProfData(uint32_t ValueKind, uint64_t N, uint64_t D,
1054 function_ref<void(instrprof_error)> Warn);
1055};
1056
1060
1061 // We reserve this bit as the flag for context sensitive profile record.
1062 static const int CS_FLAG_IN_FUNC_HASH = 60;
1063
1066 std::vector<uint64_t> Counts)
1069 std::vector<uint64_t> Counts,
1070 std::vector<uint8_t> BitmapBytes)
1072 Hash(Hash) {}
1073
1074 static bool hasCSFlagInHash(uint64_t FuncHash) {
1075 return ((FuncHash >> CS_FLAG_IN_FUNC_HASH) & 1);
1076 }
1077 static void setCSFlagInHash(uint64_t &FuncHash) {
1078 FuncHash |= ((uint64_t)1 << CS_FLAG_IN_FUNC_HASH);
1079 }
1080};
1081
1083 uint32_t NumValueKinds = 0;
1084 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
1085 NumValueKinds += !(getValueSitesForKind(Kind).empty());
1086 return NumValueKinds;
1087}
1088
1090 uint32_t N = 0;
1091 for (const auto &SR : getValueSitesForKind(ValueKind))
1092 N += SR.ValueData.size();
1093 return N;
1094}
1095
1097 return getValueSitesForKind(ValueKind).size();
1098}
1099
1102 return getValueSitesForKind(ValueKind)[Site].ValueData;
1103}
1104
1105void InstrProfRecord::reserveSites(uint32_t ValueKind, uint32_t NumValueSites) {
1106 if (!NumValueSites)
1107 return;
1108 getOrCreateValueSitesForKind(ValueKind).reserve(NumValueSites);
1109}
1110
1111// Include definitions for value profile data
1112#define INSTR_PROF_VALUE_PROF_DATA
1114
1117 ValueData, [](const InstrProfValueData &L, const InstrProfValueData &R) {
1118 return L.Count > R.Count;
1119 });
1120 // Now truncate
1121 size_t max_s = INSTR_PROF_MAX_NUM_VAL_PER_SITE;
1122 if (ValueData.size() > max_s)
1123 ValueData.resize(max_s);
1124}
1125
1126namespace IndexedInstrProf {
1127
1128enum class HashT : uint32_t {
1129 MD5,
1130 Last = MD5
1131};
1132
1134 switch (Type) {
1135 case HashT::MD5:
1136 return MD5Hash(K);
1137 }
1138 llvm_unreachable("Unhandled hash type");
1139}
1140
1141const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81"
1142
1144 // Version 1 is the first version. In this version, the value of
1145 // a key/value pair can only include profile data of a single function.
1146 // Due to this restriction, the number of block counters for a given
1147 // function is not recorded but derived from the length of the value.
1149 // The version 2 format supports recording profile data of multiple
1150 // functions which share the same key in one value field. To support this,
1151 // the number block counters is recorded as an uint64_t field right after the
1152 // function structural hash.
1154 // Version 3 supports value profile data. The value profile data is expected
1155 // to follow the block counter profile data.
1157 // In this version, profile summary data \c IndexedInstrProf::Summary is
1158 // stored after the profile header.
1160 // In this version, the frontend PGO stable hash algorithm defaults to V2.
1162 // In this version, the frontend PGO stable hash algorithm got fixed and
1163 // may produce hashes different from Version5.
1165 // An additional counter is added around logical operators.
1167 // An additional (optional) memory profile type is added.
1169 // Binary ids are added.
1171 // An additional (optional) temporal profile traces section is added.
1173 // An additional field is used for bitmap bytes.
1175 // VTable profiling, decision record and bitmap are modified for mcdc.
1177 // The current version is 12.
1178 CurrentVersion = INSTR_PROF_INDEX_VERSION
1181
1183
1185
1186// This structure defines the file header of the LLVM profile
1187// data file in indexed-format. Please update llvm/docs/InstrProfileFormat.rst
1188// as appropriate when updating the indexed profile format.
1189struct Header {
1191 // The lower 32 bits specify the version of the indexed profile.
1192 // The most significant 32 bits are reserved to specify the variant types of
1193 // the profile.
1195 uint64_t Unused = 0; // Becomes unused since version 4
1197 // This field records the offset of this hash table's metadata (i.e., the
1198 // number of buckets and entries), which follows right after the payload of
1199 // the entire hash table.
1205 // New fields should only be added at the end to ensure that the size
1206 // computation is correct. The methods below need to be updated to ensure that
1207 // the new field is read correctly.
1208
1209 // Reads a header struct from the buffer. Header fields are in machine native
1210 // endianness.
1211 LLVM_ABI static Expected<Header> readFromBuffer(const unsigned char *Buffer);
1212
1213 // Returns the size of the header in bytes for all valid fields based on the
1214 // version. I.e a older version header will return a smaller size.
1215 LLVM_ABI size_t size() const;
1216
1217 // Return the indexed profile version, i.e., the least significant 32 bits
1218 // in Header.Version.
1220};
1221
1222// Profile summary data recorded in the profile data file in indexed
1223// format. It is introduced in version 4. The summary data follows
1224// right after the profile file header.
1225struct Summary {
1226 struct Entry {
1227 uint64_t Cutoff; ///< The required percentile of total execution count.
1228 uint64_t
1229 MinBlockCount; ///< The minimum execution count for this percentile.
1230 uint64_t NumBlocks; ///< Number of blocks >= the minumum execution count.
1231 };
1232 // The field kind enumerator to assigned value mapping should remain
1233 // unchanged when a new kind is added or an old kind gets deleted in
1234 // the future.
1236 /// The total number of functions instrumented.
1238 /// Total number of instrumented blocks/edges.
1240 /// The maximal execution count among all functions.
1241 /// This field does not exist for profile data from IR based
1242 /// instrumentation.
1244 /// Max block count of the program.
1246 /// Max internal block count of the program (excluding entry blocks).
1248 /// The sum of all instrumented block counts.
1252
1253 // The number of summmary fields following the summary header.
1255 // The number of Cutoff Entries (Summary::Entry) following summary fields.
1257
1258 Summary() = delete;
1259 Summary(uint32_t Size) { memset(this, 0, Size); }
1260
1261 void operator delete(void *ptr) { ::operator delete(ptr); }
1262
1264 return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
1265 NumSumFields * sizeof(uint64_t);
1266 }
1267
1269 return reinterpret_cast<const uint64_t *>(this + 1);
1270 }
1271
1273 return reinterpret_cast<uint64_t *>(this + 1);
1274 }
1275
1276 const Entry *getCutoffEntryBase() const {
1277 return reinterpret_cast<const Entry *>(
1279 }
1280
1282 return reinterpret_cast<Entry *>(&getSummaryDataBase()[NumSummaryFields]);
1283 }
1284
1286 return getSummaryDataBase()[K];
1287 }
1288
1290 getSummaryDataBase()[K] = V;
1291 }
1292
1293 const Entry &getEntry(uint32_t I) const { return getCutoffEntryBase()[I]; }
1294
1296 Entry &ER = getCutoffEntryBase()[I];
1297 ER.Cutoff = E.Cutoff;
1298 ER.MinBlockCount = E.MinCount;
1299 ER.NumBlocks = E.NumCounts;
1300 }
1301};
1302
1303inline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) {
1304 return std::unique_ptr<Summary>(new (::operator new(TotalSize))
1305 Summary(TotalSize));
1306}
1307
1308} // end namespace IndexedInstrProf
1309
1310namespace RawInstrProf {
1311
1312// Version 1: First version
1313// Version 2: Added value profile data section. Per-function control data
1314// struct has more fields to describe value profile information.
1315// Version 3: Compressed name section support. Function PGO name reference
1316// from control data struct is changed from raw pointer to Name's MD5 value.
1317// Version 4: ValueDataBegin and ValueDataSizes fields are removed from the
1318// raw header.
1319// Version 5: Bit 60 of FuncHash is reserved for the flag for the context
1320// sensitive records.
1321// Version 6: Added binary id.
1322// Version 7: Reorder binary id and include version in signature.
1323// Version 8: Use relative counter pointer.
1324// Version 9: Added relative bitmap bytes pointer and count used by MC/DC.
1325// Version 10: Added vtable, a new type of value profile data.
1326const uint64_t Version = INSTR_PROF_RAW_VERSION;
1327
1328template <class IntPtrT> inline uint64_t getMagic();
1329template <> inline uint64_t getMagic<uint64_t>() {
1330 return INSTR_PROF_RAW_MAGIC_64;
1331}
1332
1333template <> inline uint64_t getMagic<uint32_t>() {
1334 return INSTR_PROF_RAW_MAGIC_32;
1335}
1336
1337// Per-function profile data header/control structure.
1338// The definition should match the structure defined in
1339// compiler-rt/lib/profile/InstrProfiling.h.
1340// It should also match the synthesized type in
1341// Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters.
1342template <class IntPtrT> struct alignas(8) ProfileData {
1343#define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
1345};
1346
1347template <class IntPtrT> struct alignas(8) VTableProfileData {
1348#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Init) Type Name;
1350};
1351
1352// File header structure of the LLVM profile data in raw format.
1353// The definition should match the header referenced in
1354// compiler-rt/lib/profile/InstrProfilingFile.c and
1355// InstrProfilingBuffer.c.
1356struct Header {
1357#define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name;
1359};
1360
1361} // end namespace RawInstrProf
1362
1363// Create the variable for the profile file name.
1364LLVM_ABI void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput);
1365
1366// Whether to compress function names in profile records, and filenames in
1367// code coverage mappings. Used by the Instrumentation library and unit tests.
1369
1370} // end namespace llvm
1371#endif // LLVM_PROFILEDATA_INSTRPROF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
DXIL Finalize Linkage
This file defines the DenseMap class.
uint64_t Addr
std::string Name
uint64_t Size
This file implements a coalescing interval map for small objects.
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
#define P(N)
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
StringSet - A set-like wrapper for the StringMap.
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Base class for user error types.
Definition: Error.h:354
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
Tagged union holding either a T or a Error.
Definition: Error.h:485
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:52
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: InstrProf.h:459
static std::pair< instrprof_error, std::string > take(Error E)
Consume an Error and return the raw enum value contained within it, and the optional error message.
Definition: InstrProf.h:471
const std::string & getMessage() const
Definition: InstrProf.h:466
static char ID
Definition: InstrProf.h:482
instrprof_error get() const
Definition: InstrProf.h:465
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: InstrProf.h:461
InstrProfError(instrprof_error Err, const Twine &ErrStr=Twine())
Definition: InstrProf.h:452
A symbol table used for function [IR]PGO name look-up with keys (such as pointers,...
Definition: InstrProf.h:506
StringRef getFuncOrVarName(uint64_t ValMD5Hash) const
Return name of functions or global variables from the name's md5 hash value.
Definition: InstrProf.h:778
static LLVM_ABI StringRef getCanonicalName(StringRef PGOName)
Definition: InstrProf.cpp:640
static bool isExternalSymbol(const StringRef &Symbol)
True if Symbol is the value used to represent external symbols.
Definition: InstrProf.h:709
const std::vector< std::pair< uint64_t, Function * > > & getIDToNameMap() const
Definition: InstrProf.h:668
Error addSymbolName(StringRef SymbolName)
Definition: InstrProf.h:636
std::vector< std::pair< uint64_t, uint64_t > > AddrHashMap
Definition: InstrProf.h:508
LLVM_ABI StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize) const
Return function's PGO name from the function name's symbol address in the object file.
InstrProfSymtab & operator=(InstrProfSymtab &&)=delete
GlobalVariable * getGlobalVariable(uint64_t MD5Hash) const
Return the global variable corresponding to md5 hash.
Definition: InstrProf.h:798
StringRef getFuncOrVarNameIfDefined(uint64_t ValMD5Hash) const
Just like getFuncOrVarName, except that it will return literal string 'External Symbol' if the functi...
Definition: InstrProf.h:771
void mapAddress(uint64_t Addr, uint64_t MD5Val)
Map a function address to its name's MD5 hash.
Definition: InstrProf.h:676
Error addVTableName(StringRef VTableName)
Adds VTableName as a known symbol, and inserts it to a map that tracks all vtable names.
Definition: InstrProf.h:658
LLVM_ABI void dumpNames(raw_ostream &OS) const
Dump the symbols in this table.
Definition: InstrProf.cpp:707
StringRef getNameData() const
Return the name section data.
Definition: InstrProf.h:721
LLVM_ABI Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
Error addFuncName(StringRef FuncName)
The method name is kept since there are many callers.
Definition: InstrProf.h:654
void mapVTableAddress(uint64_t StartAddr, uint64_t EndAddr, uint64_t MD5Val)
Map the address range (i.e., [start_address, end_address)) of a variable to its names' MD5 hash.
Definition: InstrProf.h:683
LLVM_ABI Error initVTableNamesFromCompressedStrings(StringRef CompressedVTableNames)
Initialize 'this' with the set of vtable names encoded in CompressedVTableNames.
Definition: InstrProf.cpp:634
const StringSet & getVTableNames() const
Definition: InstrProf.h:672
LLVM_ABI uint64_t getVTableHashFromAddress(uint64_t Address) const
Return a vtable's hash, or 0 if the vtable doesn't exist in this SymTab.
Definition: InstrProf.cpp:687
Function * getFunction(uint64_t FuncMD5Hash) const
Return function from the name's md5 hash. Return nullptr if not found.
Definition: InstrProf.h:788
InstrProfSymtab & operator=(const InstrProfSymtab &)=delete
InstrProfSymtab(InstrProfSymtab &&)=delete
InstrProfSymtab(const InstrProfSymtab &)=delete
LLVM_ABI uint64_t getFunctionHashFromAddress(uint64_t Address) const
Return a function's hash, or 0, if the function isn't in this SymTab.
Definition: InstrProf.cpp:693
void insert(KeyT a, KeyT b, ValT y)
insert - Add a mapping of [a;b] to y, coalesce with adjacent intervals.
Definition: IntervalMap.h:1130
typename Sizer::Allocator Allocator
Definition: IntervalMap.h:963
Definition: MD5.h:42
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:303
raw_ostream & OS
Definition: InstrProf.h:88
LLVM_ABI uint64_t tell() const
Definition: InstrProf.cpp:269
LLVM_ABI void writeByte(uint8_t V)
Definition: InstrProf.cpp:272
LLVM_ABI void patch(ArrayRef< PatchItem > P)
Definition: InstrProf.cpp:274
LLVM_ABI void write32(uint32_t V)
Definition: InstrProf.cpp:271
support::endian::Writer LE
Definition: InstrProf.h:89
LLVM_ABI void write(uint64_t V)
Definition: InstrProf.cpp:270
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:25
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition: StringSet.h:39
ObjectFormatType
Definition: Triple.h:314
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
An efficient, type-erasing, non-owning reference to a callable.
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:83
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:461
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:662
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ValueKind
Value kinds.
std::unique_ptr< Summary > allocSummary(uint32_t TotalSize)
Definition: InstrProf.h:1303
uint64_t ComputeHash(StringRef K)
Definition: InstrProf.h:1184
const uint64_t Version
Definition: InstrProf.h:1180
const uint64_t Magic
Definition: InstrProf.h:1141
const HashT HashType
Definition: InstrProf.h:1182
uint64_t getMagic()
const uint64_t Version
Definition: InstrProf.h:1326
uint64_t getMagic< uint32_t >()
Definition: InstrProf.h:1333
uint64_t getMagic< uint64_t >()
Definition: InstrProf.h:1329
constexpr size_t NameSize
Definition: XCOFF.h:30
template class LLVM_TEMPLATE_ABI opt< bool >
Definition: CommandLine.cpp:79
uint64_t MD5Hash(const FunctionId &Obj)
Definition: FunctionId.h:167
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void stable_sort(R &&Range)
Definition: STLExtras.h:2077
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
Definition: InstrProf.h:124
LLVM_ABI std::string getPGOFuncName(const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Please use getIRPGOFuncName for LLVM IR instrumentation.
Definition: InstrProf.cpp:421
StringRef getInstrProfRuntimeHookVarName()
Return the name of the hook variable defined in profile runtime library.
Definition: InstrProf.h:195
LLVM_ABI void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
Definition: InstrProf.cpp:1460
LLVM_ABI std::string getIRPGOFuncName(const Function &F, bool InLTO=false)
Definition: InstrProf.cpp:410
std::error_code make_error_code(BitcodeError E)
StringRef getPGOFuncNameMetadataName()
Definition: InstrProf.h:342
StringRef getCoverageMappingVarName()
Return the name of a covarage mapping variable (internal linkage) for each instrumented source module...
Definition: InstrProf.h:153
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:990
StringRef getInstrProfBitmapVarPrefix()
Return the name prefix of profile bitmap variables.
Definition: InstrProf.h:136
LLVM_ABI cl::opt< bool > DoInstrProfNameCompression
LLVM_ABI 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:452
LLVM_ABI void createPGONameMetadata(GlobalObject &GO, StringRef PGOName)
Create the PGOName metadata if a global object's PGO name is different from its mangled name.
Definition: InstrProf.cpp:1464
StringRef getInstrProfVTableNamesVarName()
Definition: InstrProf.h:148
LLVM_ABI std::pair< StringRef, StringRef > getParsedIRPGOName(StringRef IRPGOName)
Definition: InstrProf.cpp:445
auto unique(Range &&R, Predicate P)
Definition: STLExtras.h:2095
LLVM_ABI MDNode * getPGOFuncNameMetadata(const Function &F)
Return the PGOFuncName meta data associated with a function.
Definition: InstrProf.cpp:1440
StringRef getInstrProfDataVarPrefix()
Return the name prefix of variables containing per-function control data.
Definition: InstrProf.h:130
StringRef getCoverageUnusedNamesVarName()
Return the name of the internal variable recording the array of PGO name vars referenced by the cover...
Definition: InstrProf.h:161
LLVM_ABI std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
Definition: InstrProf.cpp:238
uint64_t getInstrMaxCountValue()
Return the max count value. We reserver a few large values for special use.
Definition: InstrProf.h:98
LLVM_ABI bool needsComdatForCounter(const GlobalObject &GV, const Module &M)
Check if we can use Comdat for profile variables.
Definition: InstrProf.cpp:1468
LLVM_ABI std::string getPGOName(const GlobalVariable &V, bool InLTO=false)
Definition: InstrProf.cpp:437
StringRef getInstrProfInitFuncName()
Return the name of the runtime initialization method that is generated by the compiler.
Definition: InstrProf.h:190
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
Definition: InstrProf.h:139
StringRef getInstrProfCounterBiasVarName()
Definition: InstrProf.h:205
LLVM_ABI GlobalVariable * createPGOFuncNameVar(Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
Definition: InstrProf.cpp:524
LLVM_ABI 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:1334
StringRef getInstrProfRuntimeHookVarUseFuncName()
Return the name of the compiler generated function that references the runtime hook variable.
Definition: InstrProf.h:201
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
Definition: InstrProf.h:170
LLVM_ABI Error collectPGOFuncNameStrings(ArrayRef< GlobalVariable * > NameVars, std::string &Result, bool doCompression=true)
Produce Result string with the same format described above.
Definition: InstrProf.cpp:759
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1669
InstrProfSectKind
Definition: InstrProf.h:92
LLVM_ABI Error readAndDecodeStrings(StringRef NameStrings, std::function< Error(StringRef)> NameCallback)
NameStrings is a string composed of one or more possibly encoded sub-strings.
Definition: InstrProf.cpp:576
StringRef getInstrProfCountersVarPrefix()
Return the name prefix of profile counter variables.
Definition: InstrProf.h:133
LLVM_ABI StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
Definition: InstrProf.cpp:752
StringRef getInstrProfBitmapBiasVarName()
Definition: InstrProf.h:209
StringRef getInstrProfNameSeparator()
Return the marker used to separate PGO names during serialization.
Definition: InstrProf.h:214
LLVM_ABI SmallVector< InstrProfValueData, 4 > getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst and returns them if Inst is annotated with value profile dat...
Definition: InstrProf.cpp:1402
StringRef getInstrProfValueProfMemOpFuncName()
Return the name profile runtime entry point to do memop size value profiling.
Definition: InstrProf.h:119
@ Other
Any other memory.
instrprof_error
Definition: InstrProf.h:399
InstrProfValueKind
Definition: InstrProf.h:312
StringRef getInstrProfNamesRegFuncName()
Return the name of the runtime interface that registers the PGO name strings.
Definition: InstrProf.h:182
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:2013
LLVM_ABI const std::error_category & instrprof_category()
Definition: InstrProf.cpp:193
LLVM_ABI Error collectVTableStrings(ArrayRef< GlobalVariable * > VTables, std::string &Result, bool doCompression)
Definition: InstrProf.cpp:769
LLVM_ABI bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
Definition: InstrProf.cpp:1516
LLVM_ABI void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
Definition: InstrProf.cpp:1539
LLVM_ABI Error collectGlobalObjectNameStrings(ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (names of global objects like functions or, virtual tables) NameStrs,...
Definition: InstrProf.cpp:714
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:1886
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
Definition: InstrProf.h:113
StringRef getInstrProfRegFuncName()
Return the name of the runtime interface that registers per-function control data for one instrumente...
Definition: InstrProf.h:176
LLVM_ABI 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:464
StringRef getInstrProfNamesVarName()
Return the name of the variable holding the strings (possibly compressed) of all function's PGO names...
Definition: InstrProf.h:146
LLVM_ABI bool isGPUProfTarget(const Module &M)
Determines whether module targets a GPU eligable for PGO instrumentation.
Definition: InstrProf.cpp:482
LLVM_ABI bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
Definition: InstrProf.cpp:1494
StringRef getPGONameMetadataName()
Definition: InstrProf.h:344
StringRef getInstrProfVNodesVarName()
Return the name of value profile node array variables:
Definition: InstrProf.h:142
StringRef getInstrProfVTableVarPrefix()
Return the name prefix of variables containing virtual table profile data.
Definition: InstrProf.h:127
InstrProfKind
An enum describing the attributes of an instrumented profile.
Definition: InstrProf.h:374
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
#define N
std::array< double, IPVK_Last - IPVK_First+1 > ValueCounts
Definition: InstrProf.h:807
LLVM_ABI uint64_t getIndexedProfileVersion() const
Definition: InstrProf.cpp:1716
LLVM_ABI size_t size() const
Definition: InstrProf.cpp:1720
static LLVM_ABI Expected< Header > readFromBuffer(const unsigned char *Buffer)
Definition: InstrProf.cpp:1676
uint64_t Cutoff
The required percentile of total execution count.
Definition: InstrProf.h:1227
uint64_t NumBlocks
Number of blocks >= the minumum execution count.
Definition: InstrProf.h:1230
uint64_t MinBlockCount
The minimum execution count for this percentile.
Definition: InstrProf.h:1229
const Entry * getCutoffEntryBase() const
Definition: InstrProf.h:1276
uint64_t get(SummaryFieldKind K) const
Definition: InstrProf.h:1285
void set(SummaryFieldKind K, uint64_t V)
Definition: InstrProf.h:1289
void setEntry(uint32_t I, const ProfileSummaryEntry &E)
Definition: InstrProf.h:1295
@ TotalNumFunctions
The total number of functions instrumented.
Definition: InstrProf.h:1237
@ TotalNumBlocks
Total number of instrumented blocks/edges.
Definition: InstrProf.h:1239
@ MaxFunctionCount
The maximal execution count among all functions.
Definition: InstrProf.h:1243
@ TotalBlockCount
The sum of all instrumented block counts.
Definition: InstrProf.h:1249
@ MaxBlockCount
Max block count of the program.
Definition: InstrProf.h:1245
@ MaxInternalBlockCount
Max internal block count of the program (excluding entry blocks).
Definition: InstrProf.h:1247
const uint64_t * getSummaryDataBase() const
Definition: InstrProf.h:1268
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries)
Definition: InstrProf.h:1263
const Entry & getEntry(uint32_t I) const
Definition: InstrProf.h:1293
Profiling information for a single function.
Definition: InstrProf.h:895
LLVM_ABI void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap of value profile counts.
Definition: InstrProf.cpp:828
std::vector< uint64_t > Counts
Definition: InstrProf.h:896
ArrayRef< InstrProfValueData > getValueArrayForSite(uint32_t ValueKind, uint32_t Site) const
Return the array of profiled values at Site.
Definition: InstrProf.h:1101
CountPseudoKind getCountPseudoKind() const
Definition: InstrProf.h:994
InstrProfRecord(std::vector< uint64_t > Counts)
Definition: InstrProf.h:900
LLVM_ABI void accumulateCounts(CountSumOrPercent &Sum) const
Compute the sums of all counts and store in Sum.
Definition: InstrProf.cpp:779
uint32_t getNumValueSites(uint32_t ValueKind) const
Return the number of instrumented sites for ValueKind.
Definition: InstrProf.h:1096
uint32_t getNumValueKinds() const
Return the number of value profile kinds with non-zero number of profile sites.
Definition: InstrProf.h:1082
void setPseudoCount(CountPseudoKind Kind)
Definition: InstrProf.h:1002
InstrProfRecord(InstrProfRecord &&)=default
uint32_t getNumValueData(uint32_t ValueKind) const
Return the total number of ValueData for ValueKind.
Definition: InstrProf.h:1089
LLVM_ABI void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
Definition: InstrProf.cpp:957
LLVM_ABI void addValueData(uint32_t ValueKind, uint32_t Site, ArrayRef< InstrProfValueData > VData, InstrProfSymtab *SymTab)
Add ValueData for ValueKind at value Site.
Definition: InstrProf.cpp:1052
InstrProfRecord & operator=(const InstrProfRecord &RHS)
Definition: InstrProf.h:911
void clearValueData()
Clear value data entries.
Definition: InstrProf.h:971
InstrProfRecord(const InstrProfRecord &RHS)
Definition: InstrProf.h:905
InstrProfRecord(std::vector< uint64_t > Counts, std::vector< uint8_t > BitmapBytes)
Definition: InstrProf.h:901
void reserveSites(uint32_t ValueKind, uint32_t NumValueSites)
Reserve space for NumValueSites sites.
Definition: InstrProf.h:1105
LLVM_ABI void overlap(InstrProfRecord &Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff)
Compute the overlap b/w this IntrprofRecord and Other.
Definition: InstrProf.cpp:846
void sortValueData()
Sort value profile data (per site) by count.
Definition: InstrProf.h:958
std::vector< uint8_t > BitmapBytes
Definition: InstrProf.h:897
InstrProfRecord & operator=(InstrProfRecord &&)=default
void Clear()
Clear value data entries and edge counters.
Definition: InstrProf.h:965
LLVM_ABI 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:1020
void sortByCount()
Sort ValueData Descending by Count.
Definition: InstrProf.h:1115
InstrProfValueSiteRecord(std::vector< InstrProfValueData > &&VD)
Definition: InstrProf.h:868
void sortByTargetValues()
Sort ValueData ascending by Value.
Definition: InstrProf.h:872
std::vector< InstrProfValueData > ValueData
Value profiling data pairs at a given value site.
Definition: InstrProf.h:865
LLVM_ABI 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:897
LLVM_ABI void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap b/w this record and Input record.
Definition: InstrProf.cpp:797
LLVM_ABI 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:926
static bool hasCSFlagInHash(uint64_t FuncHash)
Definition: InstrProf.h:1074
NamedInstrProfRecord(StringRef Name, uint64_t Hash, std::vector< uint64_t > Counts)
Definition: InstrProf.h:1065
NamedInstrProfRecord(StringRef Name, uint64_t Hash, std::vector< uint64_t > Counts, std::vector< uint8_t > BitmapBytes)
Definition: InstrProf.h:1068
static void setCSFlagInHash(uint64_t &FuncHash)
Definition: InstrProf.h:1077
static const int CS_FLAG_IN_FUNC_HASH
Definition: InstrProf.h:1062
const std::string NameFilter
Definition: InstrProf.h:860
LLVM_ABI void addOneMismatch(const CountSumOrPercent &MismatchFunc)
Definition: InstrProf.cpp:1584
static double score(uint64_t Val1, uint64_t Val2, double Sum1, double Sum2)
Definition: InstrProf.h:848
LLVM_ABI Error accumulateCounts(const std::string &BaseFilename, const std::string &TestFilename, bool IsCS)
Definition: InstrProf.cpp:1556
LLVM_ABI void dump(raw_fd_ostream &OS) const
Definition: InstrProf.cpp:1603
CountSumOrPercent Overlap
Definition: InstrProf.h:824
CountSumOrPercent Base
Definition: InstrProf.h:820
uint64_t FuncHash
Definition: InstrProf.h:831
LLVM_ABI void addOneUnique(const CountSumOrPercent &UniqueFunc)
Definition: InstrProf.cpp:1594
const std::string * BaseFilename
Definition: InstrProf.h:828
const std::string * TestFilename
Definition: InstrProf.h:829
void setFuncInfo(StringRef Name, uint64_t Hash)
Definition: InstrProf.h:838
CountSumOrPercent Unique
Definition: InstrProf.h:826
CountSumOrPercent Mismatch
Definition: InstrProf.h:825
StringRef FuncName
Definition: InstrProf.h:830
OverlapStatsLevel Level
Definition: InstrProf.h:827
OverlapStats(OverlapStatsLevel L=ProgramLevel)
Definition: InstrProf.h:834
CountSumOrPercent Test
Definition: InstrProf.h:822
uint64_t Pos
Definition: InstrProf.h:64
ArrayRef< uint64_t > D
Definition: InstrProf.h:65
An ordered list of functions identified by their NameRef found in INSTR_PROF_DATA.
Definition: InstrProf.h:430
static LLVM_ABI void createBPFunctionNodes(ArrayRef< TemporalProfTraceTy > Traces, std::vector< BPFunctionNode > &Nodes, bool RemoveOutlierUNs=true)
Use a set of temporal profile traces to create a list of balanced partitioning function nodes used by...
Definition: InstrProf.cpp:1071
std::vector< uint64_t > FunctionNameRefs
Definition: InstrProf.h:431
TemporalProfTraceTy(std::initializer_list< uint64_t > Trace={}, uint64_t Weight=1)
Definition: InstrProf.h:433
Function object to check whether the first component of a container supported by std::get (like std::...
Definition: STLExtras.h:1472
Adapter to write values to a stream in a particular byte order.
Definition: EndianStream.h:67