15#ifndef LLVM_PROFILEDATA_INSTRPROF_H
16#define LLVM_PROFILEDATA_INSTRPROF_H
46#include <system_error>
92#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) Kind,
98 return std::numeric_limits<uint64_t>::max() - 2;
108 bool AddSegmentInfo =
true);
156 return "__llvm_prf_nm_postfix";
165 return "__llvm_coverage_mapping";
173 return "__llvm_coverage_names";
182 return "__llvm_profile_register_functions";
188 return "__llvm_profile_register_function";
194 return "__llvm_profile_register_names_function";
213 return "__llvm_profile_runtime_user";
255LLVM_ABI std::pair<StringRef, StringRef>
270 StringRef PGOFuncName);
278 StringRef PGOFuncName);
286 StringRef FileName =
"<unknown>");
299 std::string &Result);
308 bool doCompression =
true);
311 std::string &Result,
bool doCompression);
321 bool CheckAddressTaken =
false);
324#define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value,
351 bool GetNoICPValue =
false);
382 StringRef NameStrings, std::function<
Error(StringRef)> NameCallback);
453 std::vector<BPFunctionNode> &Nodes,
454 bool RemoveOutlierUNs =
true);
464 : Err(Err), Msg(ErrStr.str()) {
468 std::string message()
const override;
482 static std::pair<instrprof_error, std::string>
take(
Error E) {
484 std::string Msg =
"";
527 using AddrIntervalMap =
540 mutable std::vector<std::pair<uint64_t, StringRef>> MD5NameMap;
543 mutable std::vector<std::pair<uint64_t, Function *>> MD5FuncMap;
556 AddrIntervalMap VTableAddrMap;
560 mutable bool Sorted =
false;
562 static StringRef getExternalSymbol() {
return "** External Symbol **"; }
585 inline void finalizeSymtab()
const;
632 bool AddCanonical =
true);
636 template <
typename NameIterRange>
642 template <
typename FuncNameIterRange,
typename VTableNameIterRange>
643 Error create(
const FuncNameIterRange &FuncIterRange,
644 const VTableNameIterRange &VTableIterRange);
648 if (SymbolName.empty())
650 "symbol name is empty");
654 auto Ins = NameTab.insert(SymbolName);
656 MD5NameMap.push_back(std::make_pair(
675 VTableNames.insert(VTableName);
688 AddrToMD5Map.push_back(std::make_pair(Addr, MD5Val));
695 VTableAddrMap.insert(StartAddr, EndAddr, MD5Val);
721 return Symbol == InstrProfSymtab::getExternalSymbol();
744template <
typename NameIterRange>
746 for (
auto Name : IterRange)
754template <
typename FuncNameIterRange,
typename VTableNameIterRange>
756 const VTableNameIterRange &VTableIterRange) {
764 for (
StringRef VTableName : VTableIterRange)
772void InstrProfSymtab::finalizeSymtab()
const {
778 AddrToMD5Map.erase(
llvm::unique(AddrToMD5Map), AddrToMD5Map.end());
785 return InstrProfSymtab::getExternalSymbol();
792 [](
const std::pair<uint64_t, StringRef> &
LHS,
794 if (Result != MD5NameMap.end() && Result->first ==
MD5Hash)
795 return Result->second;
802 [](
const std::pair<uint64_t, Function *> &
LHS,
804 if (Result != MD5FuncMap.end() && Result->first == FuncMD5Hash)
805 return Result->second;
810 return MD5VTableMap.lookup(
MD5Hash);
861 if (Sum1 < 1.0f || Sum2 < 1.0f)
863 return std::min(Val1 / Sum1, Val2 / Sum2);
885 [](
const InstrProfValueData &L,
const InstrProfValueData &R) {
886 return L.Value < R.Value;
918 ValueData(
RHS.ValueData
919 ?
std::make_unique<ValueProfData>(*
RHS.ValueData)
925 if (!
RHS.ValueData) {
930 ValueData = std::make_unique<ValueProfData>(*
RHS.ValueData);
932 *ValueData = *
RHS.ValueData;
970 for (
uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
971 for (
auto &SR : getValueSitesForKind(Kind))
1021 using ValueProfData = std::array<std::vector<InstrProfValueSiteRecord>,
1022 IPVK_Last - IPVK_First + 1>;
1023 std::unique_ptr<ValueProfData> ValueData;
1026 getValueSitesForKind(
uint32_t ValueKind) {
1030 auto AR =
const_cast<const InstrProfRecord *
>(
this)->getValueSitesForKind(
1036 getValueSitesForKind(
uint32_t ValueKind)
const {
1039 assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
1040 "Unknown value kind!");
1041 return (*ValueData)[
ValueKind - IPVK_First];
1044 std::vector<InstrProfValueSiteRecord> &
1045 getOrCreateValueSitesForKind(uint32_t ValueKind) {
1047 ValueData = std::make_unique<ValueProfData>();
1048 assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
1049 "Unknown value kind!");
1050 return (*ValueData)[
ValueKind - IPVK_First];
1054 uint64_t remapValue(uint64_t
Value, uint32_t ValueKind,
1055 InstrProfSymtab *SymTab);
1064 void scaleValueProfData(uint32_t ValueKind, uint64_t
N, uint64_t
D,
1079 std::vector<uint64_t>
Counts)
1082 std::vector<uint64_t>
Counts,
1097 for (
uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
1098 NumValueKinds += !(getValueSitesForKind(Kind).empty());
1099 return NumValueKinds;
1104 for (
const auto &SR : getValueSitesForKind(ValueKind))
1105 N += SR.ValueData.size();
1110 return getValueSitesForKind(ValueKind).size();
1115 return getValueSitesForKind(ValueKind)[Site].ValueData;
1121 getOrCreateValueSitesForKind(ValueKind).reserve(
NumValueSites);
1125#define INSTR_PROF_VALUE_PROF_DATA
1130 ValueData, [](
const InstrProfValueData &L,
const InstrProfValueData &R) {
1131 return L.Count > R.Count;
1276 void operator delete(
void *ptr) { ::operator
delete(ptr); }
1284 return reinterpret_cast<const uint64_t *
>(
this + 1);
1288 return reinterpret_cast<uint64_t *
>(
this + 1);
1292 return reinterpret_cast<const Entry *
>(
1319 return std::unique_ptr<Summary>(
new (::operator
new(TotalSize))
1358#define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
1363#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Init) Type Name;
1372#define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name;
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")
This file defines the DenseMap class.
#define INSTR_PROF_QUOTE(x)
#define INSTR_PROF_INSTRUMENT_GPU_FUNC_STR
#define INSTR_PROF_RAW_MAGIC_32
#define INSTR_PROF_MAX_NUM_VAL_PER_SITE
#define INSTR_PROF_RAW_VERSION
#define INSTR_PROF_PROFILE_BITMAP_BIAS_VAR
#define INSTR_PROF_INDEX_VERSION
#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR
#define INSTR_PROF_VALUE_PROF_FUNC_STR
#define INSTR_PROF_RAW_MAGIC_64
#define INSTR_PROF_PROFILE_RUNTIME_VAR
#define INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR
This file implements a coalescing interval map for small objects.
Machine Check Debug Module
StringSet - A set-like wrapper for the StringMap.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Base class for user error types.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
LinkageTypes
An enumeration for the kinds of linkage for global values.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
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.
const std::string & getMessage() const
instrprof_error get() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
std::string message() const override
Return the error message as a string.
InstrProfError(instrprof_error Err, const Twine &ErrStr=Twine())
A symbol table used for function [IR]PGO name look-up with keys (such as pointers,...
StringRef getFuncOrVarName(uint64_t ValMD5Hash) const
Return name of functions or global variables from the name's md5 hash value.
static LLVM_ABI StringRef getCanonicalName(StringRef PGOName)
static bool isExternalSymbol(const StringRef &Symbol)
True if Symbol is the value used to represent external symbols.
const std::vector< std::pair< uint64_t, Function * > > & getIDToNameMap() const
Error addSymbolName(StringRef SymbolName)
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.
StringRef getFuncOrVarNameIfDefined(uint64_t ValMD5Hash) const
Just like getFuncOrVarName, except that it will return literal string 'External Symbol' if the functi...
void mapAddress(uint64_t Addr, uint64_t MD5Val)
Map a function address to its name's MD5 hash.
Error addVTableName(StringRef VTableName)
Adds VTableName as a known symbol, and inserts it to a map that tracks all vtable names.
std::vector< std::pair< uint64_t, uint64_t > > AddrHashMap
LLVM_ABI void dumpNames(raw_ostream &OS) const
Dump the symbols in this table.
StringRef getNameData() const
Return the name section data.
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.
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.
LLVM_ABI Error initVTableNamesFromCompressedStrings(StringRef CompressedVTableNames)
Initialize 'this' with the set of vtable names encoded in CompressedVTableNames.
const StringSet & getVTableNames() const
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.
Function * getFunction(uint64_t FuncMD5Hash) const
Return function from the name's md5 hash. Return nullptr if not found.
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.
typename Sizer::Allocator Allocator
A Module instance is used to store all the information related to an LLVM module.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI uint64_t tell() const
LLVM_ABI void writeByte(uint8_t V)
LLVM_ABI void patch(ArrayRef< PatchItem > P)
LLVM_ABI void write32(uint32_t V)
support::endian::Writer LE
LLVM_ABI ProfOStream(raw_fd_ostream &FD)
LLVM_ABI void write(uint64_t V)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
StringSet - A wrapper for StringMap that provides set-like functionality.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
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...
A raw_ostream that writes to a file descriptor.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::unique_ptr< Summary > allocSummary(uint32_t TotalSize)
uint64_t ComputeHash(StringRef K)
uint64_t getMagic< uint32_t >()
uint64_t getMagic< uint64_t >()
constexpr size_t NameSize
uint64_t MD5Hash(const FunctionId &Obj)
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
void stable_sort(R &&Range)
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
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.
StringRef getInstrProfRuntimeHookVarName()
Return the name of the hook variable defined in profile runtime library.
LLVM_ABI void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
LLVM_ABI std::string getIRPGOFuncName(const Function &F, bool InLTO=false)
@ LLVM_MARK_AS_BITMASK_ENUM
std::error_code make_error_code(BitcodeError E)
StringRef getPGOFuncNameMetadataName()
StringRef getCoverageMappingVarName()
Return the name of a covarage mapping variable (internal linkage) for each instrumented source module...
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
StringRef getInstrProfBitmapVarPrefix()
Return the name prefix of profile bitmap variables.
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.
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.
StringRef getInstrProfVTableNamesVarName()
LLVM_ABI std::pair< StringRef, StringRef > getParsedIRPGOName(StringRef IRPGOName)
auto unique(Range &&R, Predicate P)
LLVM_ABI MDNode * getPGOFuncNameMetadata(const Function &F)
Return the PGOFuncName meta data associated with a function.
StringRef getInstrProfDataVarPrefix()
Return the name prefix of variables containing per-function control data.
StringRef getCoverageUnusedNamesVarName()
Return the name of the internal variable recording the array of PGO name vars referenced by the cover...
LLVM_ABI std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
uint64_t getInstrMaxCountValue()
Return the max count value. We reserver a few large values for special use.
LLVM_ABI bool needsComdatForCounter(const GlobalObject &GV, const Module &M)
Check if we can use Comdat for profile variables.
LLVM_ABI std::string getPGOName(const GlobalVariable &V, bool InLTO=false)
StringRef getInstrProfInitFuncName()
Return the name of the runtime initialization method that is generated by the compiler.
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
StringRef getInstrProfCounterBiasVarName()
LLVM_ABI GlobalVariable * createPGOFuncNameVar(Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
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...
StringRef getInstrProfRuntimeHookVarUseFuncName()
Return the name of the compiler generated function that references the runtime hook variable.
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
LLVM_ABI Error collectPGOFuncNameStrings(ArrayRef< GlobalVariable * > NameVars, std::string &Result, bool doCompression=true)
Produce Result string with the same format described above.
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI Error readAndDecodeStrings(StringRef NameStrings, std::function< Error(StringRef)> NameCallback)
NameStrings is a string composed of one or more possibly encoded sub-strings.
StringRef getInstrProfCountersVarPrefix()
Return the name prefix of profile counter variables.
FunctionAddr NumValueSites[IPVK_Last+1]
LLVM_ABI StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
StringRef getInstrProfBitmapBiasVarName()
StringRef getInstrProfNameSeparator()
Return the marker used to separate PGO names during serialization.
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...
StringRef getInstrProfValueProfMemOpFuncName()
Return the name profile runtime entry point to do memop size value profiling.
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
@ unable_to_correlate_profile
@ raw_profile_version_mismatch
@ counter_value_too_large
@ missing_correlation_info
@ value_site_count_mismatch
@ unexpected_correlation_info
StringRef getInstrProfNamesRegFuncName()
Return the name of the runtime interface that registers the PGO name strings.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
LLVM_ABI const std::error_category & instrprof_category()
StringRef getInstrProfVarPrefix()
Return the prefix of the name of the variables to function as a filter.
LLVM_ABI Error collectVTableStrings(ArrayRef< GlobalVariable * > VTables, std::string &Result, bool doCompression)
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
LLVM_ABI void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
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,...
StringRef getInstrProfNamesVarPostfixVarName()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StringRef getInstrProfInstrumentGPUFuncName()
Return the name of the GPU wave-cooperative counter increment helper.
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
StringRef getInstrProfRegFuncName()
Return the name of the runtime interface that registers per-function control data for one instrumente...
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.
StringRef getInstrProfNamesVarName()
Return the name of the variable holding the strings (possibly compressed) of all function's PGO names...
LogicalResult success(bool IsSuccess=true)
Utility function to generate a LogicalResult.
LLVM_ABI bool isGPUProfTarget(const Module &M)
Determines whether module targets a GPU eligable for PGO instrumentation.
LLVM_ABI bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
StringRef getPGONameMetadataName()
StringRef getInstrProfVNodesVarName()
Return the name of value profile node array variables:
StringRef getInstrProfVTableVarPrefix()
Return the name prefix of variables containing virtual table profile data.
InstrProfKind
An enum describing the attributes of an instrumented profile.
@ LoopEntriesInstrumentation
@ FunctionEntryInstrumentation
@ FrontendInstrumentation
Implement std::hash so that hash_code can be used in STL containers.
CountSumOrPercent()=default
std::array< double, IPVK_Last - IPVK_First+1 > ValueCounts
uint64_t Cutoff
The required percentile of total execution count.
uint64_t NumBlocks
Number of blocks >= the minumum execution count.
uint64_t MinBlockCount
The minimum execution count for this percentile.
const Entry * getCutoffEntryBase() const
uint64_t get(SummaryFieldKind K) const
void set(SummaryFieldKind K, uint64_t V)
Entry * getCutoffEntryBase()
void setEntry(uint32_t I, const ProfileSummaryEntry &E)
uint64_t * getSummaryDataBase()
@ TotalNumFunctions
The total number of functions instrumented.
@ TotalNumBlocks
Total number of instrumented blocks/edges.
@ MaxFunctionCount
The maximal execution count among all functions.
@ TotalBlockCount
The sum of all instrumented block counts.
@ MaxBlockCount
Max block count of the program.
@ MaxInternalBlockCount
Max internal block count of the program (excluding entry blocks).
const uint64_t * getSummaryDataBase() const
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries)
uint64_t NumSummaryFields
const Entry & getEntry(uint32_t I) const
uint64_t NumCutoffEntries
Profiling information for a single function.
LLVM_ABI void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap of value profile counts.
InstrProfRecord()=default
std::vector< uint64_t > Counts
ArrayRef< InstrProfValueData > getValueArrayForSite(uint32_t ValueKind, uint32_t Site) const
Return the array of profiled values at Site.
CountPseudoKind getCountPseudoKind() const
InstrProfRecord(std::vector< uint64_t > Counts)
LLVM_ABI void accumulateCounts(CountSumOrPercent &Sum) const
Compute the sums of all counts and store in Sum.
uint32_t getNumValueSites(uint32_t ValueKind) const
Return the number of instrumented sites for ValueKind.
uint32_t getNumValueKinds() const
Return the number of value profile kinds with non-zero number of profile sites.
void setPseudoCount(CountPseudoKind Kind)
InstrProfRecord(InstrProfRecord &&)=default
uint32_t getNumValueData(uint32_t ValueKind) const
Return the total number of ValueData for ValueKind.
LLVM_ABI void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
LLVM_ABI void addValueData(uint32_t ValueKind, uint32_t Site, ArrayRef< InstrProfValueData > VData, InstrProfSymtab *SymTab)
Add ValueData for ValueKind at value Site.
InstrProfRecord & operator=(const InstrProfRecord &RHS)
void clearValueData()
Clear value data entries.
InstrProfRecord(const InstrProfRecord &RHS)
InstrProfRecord(std::vector< uint64_t > Counts, std::vector< uint8_t > BitmapBytes)
void reserveSites(uint32_t ValueKind, uint32_t NumValueSites)
Reserve space for NumValueSites sites.
LLVM_ABI void overlap(InstrProfRecord &Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff)
Compute the overlap b/w this IntrprofRecord and Other.
void sortValueData()
Sort value profile data (per site) by count.
std::vector< uint8_t > BitmapBytes
InstrProfRecord & operator=(InstrProfRecord &&)=default
void Clear()
Clear value data entries and edge counters.
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).
void sortByCount()
Sort ValueData Descending by Count.
InstrProfValueSiteRecord(std::vector< InstrProfValueData > &&VD)
InstrProfValueSiteRecord()=default
void sortByTargetValues()
Sort ValueData ascending by Value.
std::vector< InstrProfValueData > ValueData
Value profiling data pairs at a given value site.
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.
LLVM_ABI void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap b/w this record and Input record.
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).
static bool hasCSFlagInHash(uint64_t FuncHash)
NamedInstrProfRecord(StringRef Name, uint64_t Hash, std::vector< uint64_t > Counts)
NamedInstrProfRecord(StringRef Name, uint64_t Hash, std::vector< uint64_t > Counts, std::vector< uint8_t > BitmapBytes)
static void setCSFlagInHash(uint64_t &FuncHash)
static constexpr uint64_t FUNC_HASH_MASK
NamedInstrProfRecord()=default
static constexpr unsigned CS_FLAG_IN_FUNC_HASH
const std::string NameFilter
LLVM_ABI void addOneMismatch(const CountSumOrPercent &MismatchFunc)
static double score(uint64_t Val1, uint64_t Val2, double Sum1, double Sum2)
LLVM_ABI Error accumulateCounts(const std::string &BaseFilename, const std::string &TestFilename, bool IsCS)
LLVM_ABI void dump(raw_fd_ostream &OS) const
CountSumOrPercent Overlap
LLVM_ABI void addOneUnique(const CountSumOrPercent &UniqueFunc)
const std::string * BaseFilename
const std::string * TestFilename
void setFuncInfo(StringRef Name, uint64_t Hash)
CountSumOrPercent Mismatch
OverlapStats(OverlapStatsLevel L=ProgramLevel)
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...
std::vector< uint64_t > FunctionNameRefs
TemporalProfTraceTy(std::initializer_list< uint64_t > Trace={}, uint64_t Weight=1)
Per-function header/control data structure for value profiling data in indexed format.
Function object to check whether the first component of a container supported by std::get (like std::...
Adapter to write values to a stream in a particular byte order.