52 #include <system_error> 60 cl::desc(
"Use full module build paths in the profile counter names for " 61 "static functions."));
73 cl::desc(
"Strip specified level of directory name from source path in " 74 "the profile counter name for static functions."));
83 return "Unrecognized instrumentation profile encoding format";
85 return "Invalid instrumentation profile data (bad magic)";
87 return "Invalid instrumentation profile data (file header is corrupt)";
89 return "Unsupported instrumentation profile format version";
91 return "Unsupported instrumentation profile hash type";
93 return "Too much profile data";
95 return "Truncated profile data";
97 return "Malformed instrumentation profile data";
99 return "No profile data available for function";
101 return "Function control flow change detected (hash mismatch)";
103 return "Function basic block count change detected (counter mismatch)";
105 return "Counter overflow";
107 return "Function value site count change detected (counter mismatch)";
109 return "Failed to compress data (zlib)";
111 return "Failed to uncompress data (zlib)";
113 return "Empty raw profile file";
115 return "Profile uses zlib compression but the profile reader was built without zlib support";
126 const char *
name()
const noexcept
override {
return "llvm.instrprof"; }
128 std::string message(
int IE)
const override {
143 const char *InstrProfSectNameCommon[] = {
144 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \ 149 const char *InstrProfSectNameCoff[] = {
150 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \ 155 const char *InstrProfSectNamePrefix[] = {
156 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \ 167 bool AddSegmentInfo) {
168 std::string SectName;
171 SectName = InstrProfSectNamePrefix[IPSK];
174 SectName += InstrProfSectNameCoff[IPSK];
176 SectName += InstrProfSectNameCommon[IPSK];
178 if (OF ==
Triple::MachO && IPSK == IPSK_data && AddSegmentInfo)
179 SectName +=
",regular,live_support";
196 ++NumCountMismatches;
199 ++NumCounterOverflows;
202 ++NumValueSiteCountMismatches;
228 for (
auto & CI : PathNameStr) {
237 return PathNameStr.substr(LastPos);
266 StringRef S = cast<MDString>(MD->getOperand(0))->getString();
277 if (FileName.
empty())
296 const char *InvalidChars =
"-:<>/\"'";
297 size_t found = VarName.find_first_of(InvalidChars);
298 while (found != std::string::npos) {
299 VarName[found] =
'_';
300 found = VarName.find_first_of(InvalidChars, found + 1);
343 if (
Error E = addFuncName(PGOFuncName))
350 auto pos = PGOFuncName.find(
'.');
351 if (pos != std::string::npos) {
352 const std::string &OtherFuncName = PGOFuncName.substr(0, pos);
353 if (
Error E = addFuncName(OtherFuncName))
368 [](
const std::pair<uint64_t, uint64_t> &LHS,
369 uint64_t RHS) {
return LHS.first < RHS; });
374 if (Result != AddrToMD5Map.end() && Result->first ==
Address)
375 return (uint64_t)Result->second;
380 bool doCompression, std::string &Result) {
381 assert(!NameStrs.
empty() &&
"No name data to emit");
383 uint8_t Header[16], *
P = Header;
384 std::string UncompressedNameStrings =
389 "PGO name is invalid (contains separator token)");
391 unsigned EncLen =
encodeULEB128(UncompressedNameStrings.length(),
P);
394 auto WriteStringToResult = [&](
size_t CompressedLen,
StringRef InputStr) {
397 char *HeaderStr =
reinterpret_cast<char *
>(&Header[0]);
398 unsigned HeaderLen = P - &Header[0];
399 Result.append(HeaderStr, HeaderLen);
404 if (!doCompression) {
405 return WriteStringToResult(0, UncompressedNameStrings);
416 return WriteStringToResult(CompressedNameStrings.
size(),
417 CompressedNameStrings);
423 Arr->isCString() ? Arr->getAsCString() : Arr->getAsString();
428 std::string &Result,
bool doCompression) {
429 std::vector<std::string> NameStrs;
430 for (
auto *NameVar : NameVars) {
438 const uint8_t *
P =
reinterpret_cast<const uint8_t *
>(NameStrings.
data());
439 const uint8_t *EndP =
reinterpret_cast<const uint8_t *
>(NameStrings.
data() +
447 bool isCompressed = (CompressedSize != 0);
454 StringRef CompressedNameStrings(reinterpret_cast<const char *>(P),
464 UncompressedNameStrings.
size());
467 StringRef(reinterpret_cast<const char *>(P), UncompressedSize);
468 P += UncompressedSize;
477 while (P < EndP && *P == 0)
486 this->sortByTargetValues();
488 auto I = ValueData.begin();
489 auto IE = ValueData.end();
492 while (
I !=
IE &&
I->Value < J->Value)
494 if (
I !=
IE &&
I->Value == J->Value) {
502 ValueData.insert(
I, *J);
508 for (
auto I = ValueData.begin(),
IE = ValueData.end();
I !=
IE; ++
I) {
518 void InstrProfRecord::mergeValueProfData(
521 uint32_t ThisNumValueSites = getNumValueSites(ValueKind);
523 if (ThisNumValueSites != OtherNumValueSites) {
527 if (!ThisNumValueSites)
529 std::vector<InstrProfValueSiteRecord> &ThisSiteRecords =
530 getOrCreateValueSitesForKind(ValueKind);
532 Src.getValueSitesForKind(ValueKind);
534 ThisSiteRecords[
I].merge(OtherSiteRecords[
I], Weight, Warn);
541 if (Counts.size() != Other.
Counts.size()) {
546 for (
size_t I = 0,
E = Other.
Counts.size();
I <
E; ++
I) {
555 mergeValueProfData(
Kind, Other, Weight, Warn);
558 void InstrProfRecord::scaleValueProfData(
559 uint32_t ValueKind, uint64_t Weight,
561 for (
auto &R : getValueSitesForKind(ValueKind))
562 R.scale(Weight, Warn);
567 for (
auto &Count : this->Counts) {
574 scaleValueProfData(
Kind, Weight, Warn);
578 uint64_t InstrProfRecord::remapValue(uint64_t
Value,
uint32_t ValueKind,
583 if (ValueKind == IPVK_IndirectCallTarget)
593 VData[
I].Value = remapValue(VData[
I].Value, ValueKind, ValueMap);
595 std::vector<InstrProfValueSiteRecord> &ValueSites =
596 getOrCreateValueSitesForKind(ValueKind);
598 ValueSites.emplace_back();
600 ValueSites.emplace_back(VData, VData + N);
603 #define INSTR_PROF_COMMON_API_IMPL 612 return reinterpret_cast<const InstrProfRecord *
>(Record)->getNumValueKinds();
617 ->getNumValueSites(VKind);
622 ->getNumValueData(VKind);
628 ->getNumValueDataForSite(VK, S);
633 reinterpret_cast<const InstrProfRecord *
>(R)->getValueForSite(Dst, K, S);
638 (ValueProfData *)(
new (::
operator new(TotalSizeInBytes)) ValueProfData());
639 memset(VD, 0, TotalSizeInBytes);
656 Closure.Record = &Record;
657 return getValueProfDataSize(&Closure);
661 std::unique_ptr<ValueProfData>
663 InstrProfRecordClosure.Record = &Record;
665 std::unique_ptr<ValueProfData> VPD(
666 serializeValueProfDataFrom(&InstrProfRecordClosure,
nullptr));
674 InstrProfValueData *ValueData = getValueProfRecordValueData(
this);
675 for (uint64_t VSite = 0; VSite < NumValueSites; ++VSite) {
676 uint8_t ValueDataCount = this->SiteCountArray[VSite];
678 ValueData += ValueDataCount;
687 using namespace support;
693 sys::swapByteOrder<uint32_t>(NumValueSites);
694 sys::swapByteOrder<uint32_t>(
Kind);
696 uint32_t ND = getValueProfRecordNumValueData(
this);
697 InstrProfValueData *VD = getValueProfRecordValueData(
this);
701 sys::swapByteOrder<uint64_t>(VD[
I].Value);
702 sys::swapByteOrder<uint64_t>(VD[
I].Count);
705 sys::swapByteOrder<uint32_t>(NumValueSites);
706 sys::swapByteOrder<uint32_t>(
Kind);
712 if (NumValueKinds == 0)
715 ValueProfRecord *VR = getFirstValueProfRecord(
this);
716 for (
uint32_t K = 0; K < NumValueKinds; K++) {
717 VR->deserializeTo(Record, SymTab);
718 VR = getValueProfRecordNext(VR);
724 using namespace support;
727 return endian::readNext<T, little, unaligned>(
D);
729 return endian::readNext<T, big, unaligned>(
D);
733 return std::unique_ptr<ValueProfData>(
new (::operator
new(TotalSize))
737 Error ValueProfData::checkIntegrity() {
738 if (NumValueKinds > IPVK_Last + 1)
741 if (TotalSize %
sizeof(uint64_t))
744 ValueProfRecord *VR = getFirstValueProfRecord(
this);
745 for (
uint32_t K = 0; K < this->NumValueKinds; K++) {
746 if (VR->Kind > IPVK_Last)
748 VR = getValueProfRecordNext(VR);
749 if ((
char *)VR - (
char *)
this > (
ptrdiff_t)TotalSize)
756 ValueProfData::getValueProfData(
const unsigned char *
D,
757 const unsigned char *
const BufferEnd,
759 using namespace support;
761 if (D +
sizeof(ValueProfData) > BufferEnd)
764 const unsigned char *Header =
D;
766 if (D + TotalSize > BufferEnd)
770 memcpy(VPD.get(),
D, TotalSize);
772 VPD->swapBytesToHost(Endianness);
774 Error E = VPD->checkIntegrity();
778 return std::move(VPD);
782 using namespace support;
787 sys::swapByteOrder<uint32_t>(TotalSize);
788 sys::swapByteOrder<uint32_t>(NumValueKinds);
790 ValueProfRecord *VR = getFirstValueProfRecord(
this);
791 for (
uint32_t K = 0; K < NumValueKinds; K++) {
793 VR = getValueProfRecordNext(VR);
798 using namespace support;
803 ValueProfRecord *VR = getFirstValueProfRecord(
this);
804 for (
uint32_t K = 0; K < NumValueKinds; K++) {
805 ValueProfRecord *NVR = getValueProfRecordNext(VR);
809 sys::swapByteOrder<uint32_t>(TotalSize);
810 sys::swapByteOrder<uint32_t>(NumValueKinds);
822 std::unique_ptr<InstrProfValueData[]> VD =
847 for (
auto &VD : VDs) {
861 InstrProfValueData ValueData[],
862 uint32_t &ActualNumValueData, uint64_t &TotalC) {
893 ActualNumValueData = 0;
895 for (
unsigned I = 3;
I < NOps;
I += 2) {
896 if (ActualNumValueData >= MaxNumValueData)
900 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(
I + 1));
901 if (!Value || !Count)
904 ValueData[ActualNumValueData].Count = Count->getZExtValue();
905 ActualNumValueData++;
916 if (PGOFuncName == F.
getName())
955 if (!IRInstrVar || IRInstrVar->isDeclaration() ||
956 IRInstrVar->hasLocalLinkage())
960 if (!IRInstrVar->hasInitializer())
963 const Constant *InitVal = IRInstrVar->getInitializer();
967 return (dyn_cast<ConstantInt>(InitVal)->getZExtValue() &
968 VARIANT_MASK_IR_PROF) != 0;
996 int64_t &RangeLast) {
997 static const int64_t DefaultMemOPSizeRangeStart = 0;
998 static const int64_t DefaultMemOPSizeRangeLast = 8;
999 RangeStart = DefaultMemOPSizeRangeStart;
1000 RangeLast = DefaultMemOPSizeRangeLast;
1002 if (!MemOPSizeRange.
empty()) {
1003 auto Pos = MemOPSizeRange.
find(
':');
1004 if (Pos != std::string::npos) {
1007 if (Pos < MemOPSizeRange.
size() - 1)
1012 assert(RangeLast >= RangeStart);
void setVisibility(VisibilityTypes V)
void getValueForSiteInstrProf(const void *R, InstrProfValueData *Dst, uint32_t K, uint32_t S)
cl::opt< std::string > MemOPSizeRange("memop-size-range", cl::desc("Set the range of size in memory intrinsic calls to be profiled " "precisely, in a format of <start_val>:<end_val>"), cl::init(""))
bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
DiagnosticInfoOptimizationBase::Argument NV
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
uint32_t getNumValueDataInstrProf(const void *Record, uint32_t VKind)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This class represents lattice values for constants.
ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
A Module instance is used to store all the information related to an LLVM module. ...
void addValueData(uint32_t ValueKind, uint32_t Site, InstrProfValueData *VData, uint32_t N, InstrProfSymtab *SymTab)
Add ValueData for ValueKind at value Site.
static MDString * get(LLVMContext &Context, StringRef Str)
uint32_t getNumValueDataForSite(uint32_t ValueKind, uint32_t Site) const
Return the number of value data collected for ValueKind at profiling site: Site.
Available for inspection, not emission.
void push_back(const T &Elt)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
MDNode * getPGOFuncNameMetadata(const Function &F)
Return the PGOFuncName meta data associated with a function.
An efficient, type-erasing, non-owning reference to a callable.
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Like Internal, but omit from symbol table.
Externally visible function.
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
static std::unique_ptr< ValueProfData > allocValueProfData(uint32_t TotalSize)
static T swapToHostOrder(const unsigned char *&D, support::endianness Orig)
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
const MDOperand & getOperand(unsigned I) const
static IntegerType * getInt64Ty(LLVMContext &C)
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e...
std::enable_if< std::is_unsigned< T >::value, T >::type SaturatingMultiply(T X, T Y, bool *ResultOverflowed=nullptr)
Multiply two unsigned integers, X and Y, of type T.
void reserveSites(uint32_t ValueKind, uint32_t NumValueSites)
Reserve space for NumValueSites sites.
uint32_t getNumValueSites(uint32_t ValueKind) const
Return the number of instrumented sites for ValueKind.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static bool isLocalLinkage(LinkageTypes Linkage)
uint32_t getNumValueKindsInstrProf(const void *Record)
ValueProfRecordClosure Interface implementation for InstrProfRecord class.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
void merge(InstrProfValueSiteRecord &Input, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge data from another InstrProfValueSiteRecord Optionally scale merged counts by Weight...
Error compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, int Level=DefaultCompression)
LLVMContext & getContext() const
Get the global data context.
void scale(uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Scale up profile counts (including value profile data) by Weight.
const std::error_category & instrprof_category()
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Error collectPGOFuncNameStrings(ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (function PGO names) NameStrs, the method generates a combined string Resul...
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
Tagged union holding either a T or a Error.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName="<unknown>")
Given a PGO function name, remove the filename prefix and return the original (static) function name...
Type * getType() const
All values are typed, get the type of this value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
StringRef getInstrProfNameSeparator()
Return the marker used to separate PGO names during serialization.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
void addError(instrprof_error IE)
Track a soft error (IE) and increment its associated counter.
LinkageTypes getLinkage() const
static constexpr int BestSizeCompression
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
const std::string & getSourceFileName() const
Get the module's original source file name.
bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
static cl::opt< bool > StaticFuncFullModulePrefix("static-func-full-module-prefix", cl::init(true), cl::Hidden, cl::desc("Use full module build paths in the profile counter names for " "static functions."))
static ManagedStatic< InstrProfErrorCategoryType > ErrorCategory
std::string message() const override
Return the error message as a string.
StringRef getString() const
ExternalWeak linkage description.
uint64_t getFunctionHashFromAddress(uint64_t Address)
Return a function's hash, or 0, if the function isn't in this SymTab.
void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart, int64_t &RangeLast)
bool needsComdatForCounter(const Function &F, const Module &M)
Check if we can use Comdat for profile variables.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Same, but only replaced by something equivalent.
initializer< Ty > init(const Ty &Val)
bool getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, InstrProfValueData ValueData[], uint32_t &ActualNumValueData, uint64_t &TotalC)
Extract the value profile data from Inst which is annotated with value profile meta data...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void scale(uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Scale up value profile data counts.
std::string getPGOFuncNameVarName(StringRef FuncName, GlobalValue::LinkageTypes Linkage)
Return the name of the global variable used to store a function name in PGO instrumentation.
This is an important class for using LLVM in a threaded context.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static ValueProfRecordClosure InstrProfRecordClosure
ValueProfData * allocValueProfDataInstrProf(size_t TotalSizeInBytes)
static ManagedStatic< _object_error_category > error_category
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
std::list< InstrProfValueData > ValueData
Value profiling data pairs at a given value site.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
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...
Value(Type *Ty, unsigned scid)
void consumeError(Error Err)
Consume a Error without doing anything.
void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab)
NameStrings is a string composed of one of more sub-strings encoded in the format described above...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Triple - Helper class for working with autoconf configuration names.
bool isDiscardableIfUnused() const
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::enable_if< std::is_unsigned< T >::value, T >::type SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed=nullptr)
Multiply two unsigned integers, X and Y, and add the unsigned integer, A to the product.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
static ErrorSuccess success()
Create a success value.
This is the shared class of boolean and integer constants.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Keep one copy of function when linking (inline)
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static cl::opt< unsigned > StaticFuncStripDirNamePrefix("static-func-strip-dirname-prefix", cl::init(0), cl::Hidden, cl::desc("Strip specified level of directory name from source path in " "the profile counter name for static functions."))
static std::string getInstrProfErrString(instrprof_error Err)
StringRef getPGOFuncNameMetadataName()
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
LinkageTypes
An enumeration for the kinds of linkage for global values.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
void sortByTargetValues()
Sort ValueData ascending by Value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
void setMetadata(unsigned KindID, MDNode *MD)
Set a particular kind of metadata attachment.
std::vector< uint64_t > Counts
pointer data()
Return a pointer to the vector's buffer, even if empty().
Profiling information for a single function.
static IntegerType * getInt32Ty(LLVMContext &C)
std::string getPGOFuncName(const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Return the modified name for function F suitable to be used the key for profile lookup.
MDString * createString(StringRef Str)
Return the given string as metadata.
Error addFuncName(StringRef FuncName)
Update the symtab by adding FuncName to the table.
StringRef getName() const
Return a constant reference to the value's name.
GlobalVariable * createPGOFuncNameVar(Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
Rename collisions when linking (static functions).
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
uint32_t getNumValueSitesInstrProf(const void *Record, uint32_t VKind)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
support::endianness getHostEndianness()
StringRef - Represent a constant reference to a string, i.e.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
std::unique_ptr< InstrProfValueData[]> getValueForSite(uint32_t ValueKind, uint32_t Site, uint64_t *TotalC=nullptr) const
Return the array of profiled values at Site.
#define LLVM_ATTRIBUTE_UNUSED
unsigned getNumOperands() const
Return number of MDNode operands.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
uint32_t getNumValueDataForSiteInstrProf(const void *R, uint32_t VK, uint32_t S)
Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize)
StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
bool empty() const
empty - Check if the array is empty.