Go to the documentation of this file.
21 #include "llvm/Config/config.h"
53 #include <system_error>
54 #include <type_traits>
62 cl::desc(
"Use full module build paths in the profile counter names for "
63 "static functions."));
75 cl::desc(
"Strip specified level of directory name from source path in "
76 "the profile counter name for static functions."));
79 const std::string &ErrMsg =
"") {
91 OS <<
"unrecognized instrumentation profile encoding format";
94 OS <<
"invalid instrumentation profile data (bad magic)";
97 OS <<
"invalid instrumentation profile data (file header is corrupt)";
100 OS <<
"unsupported instrumentation profile format version";
103 OS <<
"unsupported instrumentation profile hash type";
106 OS <<
"too much profile data";
109 OS <<
"truncated profile data";
112 OS <<
"malformed instrumentation profile data";
115 OS <<
"debug info for correlation is required";
118 OS <<
"debug info for correlation is not necessary";
121 OS <<
"unable to correlate profile";
124 OS <<
"invalid profile created. Please file a bug "
125 "at: " BUG_REPORT_URL
126 " and include the profraw files that caused this error.";
129 OS <<
"no profile data available for function";
132 OS <<
"function control flow change detected (hash mismatch)";
135 OS <<
"function basic block count change detected (counter mismatch)";
138 OS <<
"counter overflow";
141 OS <<
"function value site count change detected (counter mismatch)";
144 OS <<
"failed to compress data (zlib)";
147 OS <<
"failed to uncompress data (zlib)";
150 OS <<
"empty raw profile file";
153 OS <<
"profile uses zlib compression but the profile reader was built "
154 "without zlib support";
160 OS <<
": " << ErrMsg;
171 const char *
name()
const noexcept
override {
return "llvm.instrprof"; }
173 std::string
message(
int IE)
const override {
188 const char *InstrProfSectNameCommon[] = {
189 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \
194 const char *InstrProfSectNameCoff[] = {
195 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \
200 const char *InstrProfSectNamePrefix[] = {
201 #define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) \
211 "enable-name-compression",
216 bool AddSegmentInfo) {
217 std::string SectName;
220 SectName = InstrProfSectNamePrefix[IPSK];
223 SectName += InstrProfSectNameCoff[IPSK];
225 SectName += InstrProfSectNameCommon[IPSK];
227 if (OF ==
Triple::MachO && IPSK == IPSK_data && AddSegmentInfo)
228 SectName +=
",regular,live_support";
245 ++NumCountMismatches;
248 ++NumCounterOverflows;
251 ++NumValueSiteCountMismatches;
277 for (
auto & CI : PathNameStr) {
286 return PathNameStr.substr(LastPos);
304 StringRef FileName(
F.getParent()->getSourceFileName());
315 StringRef S = cast<MDString>(MD->getOperand(0))->getString();
326 if (FileName.
empty())
345 const char *InvalidChars =
"-:<>/\"'";
346 size_t found =
VarName.find_first_of(InvalidChars);
347 while (found != std::string::npos) {
349 found =
VarName.find_first_of(InvalidChars, found + 1);
405 const std::string UniqSuffix =
".__uniq.";
406 auto pos = PGOFuncName.find(UniqSuffix);
409 if (pos != std::string::npos)
410 pos += UniqSuffix.length();
413 pos = PGOFuncName.find(
'.', pos);
414 if (pos != std::string::npos && pos != 0) {
415 const std::string &OtherFuncName = PGOFuncName.substr(0, pos);
428 auto It =
partition_point(AddrToMD5Map, [=](std::pair<uint64_t, uint64_t> A) {
429 return A.first < Address;
435 if (It != AddrToMD5Map.end() && It->first == Address)
441 bool doCompression, std::string &Result) {
442 assert(!NameStrs.
empty() &&
"No name data to emit");
444 uint8_t Header[16], *
P = Header;
445 std::string UncompressedNameStrings =
450 "PGO name is invalid (contains separator token)");
452 unsigned EncLen =
encodeULEB128(UncompressedNameStrings.length(),
P);
455 auto WriteStringToResult = [&](
size_t CompressedLen,
StringRef InputStr) {
458 char *HeaderStr =
reinterpret_cast<char *
>(&Header[0]);
459 unsigned HeaderLen =
P - &Header[0];
460 Result.append(HeaderStr, HeaderLen);
465 if (!doCompression) {
466 return WriteStringToResult(0, UncompressedNameStrings);
473 return WriteStringToResult(CompressedNameStrings.size(),
474 CompressedNameStrings);
480 Arr->isCString() ? Arr->getAsCString() : Arr->getAsString();
485 std::string &Result,
bool doCompression) {
486 std::vector<std::string> NameStrs;
487 for (
auto *NameVar : NameVars) {
496 const uint8_t *EndP = NameStrings.
bytes_end();
503 bool isCompressed = (CompressedSize != 0);
510 StringRef CompressedNameStrings(
reinterpret_cast<const char *
>(
P),
519 NameStrings =
StringRef(UncompressedNameStrings.data(),
520 UncompressedNameStrings.size());
523 StringRef(
reinterpret_cast<const char *
>(
P), UncompressedSize);
524 P += UncompressedSize;
533 while (
P < EndP && *
P == 0)
546 for (
uint32_t VK = IPVK_First; VK <= IPVK_Last; ++VK) {
549 for (
size_t I = 0;
I < NumValueSites; ++
I) {
553 KindSum += VD[V].Count;
565 double Score = 0.0f, FuncLevelScore = 0.0f;
568 auto J = Input.ValueData.begin();
569 auto JE = Input.ValueData.end();
570 while (
I !=
IE && J != JE) {
571 if (
I->Value == J->Value) {
579 }
else if (
I->Value < J->Value) {
596 if (!ThisNumValueSites)
599 std::vector<InstrProfValueSiteRecord> &ThisSiteRecords =
614 bool Mismatch = (
Counts.size() !=
Other.Counts.size());
621 if (ThisNumValueSites != OtherNumValueSites) {
639 for (
size_t I = 0,
E =
Other.Counts.size();
I <
E; ++
I) {
647 if (MaxCount >= ValueCutoff) {
648 double FuncScore = 0.0;
649 for (
size_t I = 0,
E =
Other.Counts.size();
I <
E; ++
I)
655 FuncLevelOverlap.
Valid =
true;
666 for (
const InstrProfValueData &J : Input.ValueData) {
667 while (
I !=
IE &&
I->Value < J.Value)
669 if (
I !=
IE &&
I->Value == J.Value) {
693 void InstrProfRecord::mergeValueProfData(
698 if (ThisNumValueSites != OtherNumValueSites) {
702 if (!ThisNumValueSites)
704 std::vector<InstrProfValueSiteRecord> &ThisSiteRecords =
709 ThisSiteRecords[
I].
merge(OtherSiteRecords[
I], Weight, Warn);
721 for (
size_t I = 0,
E =
Other.Counts.size();
I <
E; ++
I) {
730 mergeValueProfData(
Kind,
Other, Weight, Warn);
733 void InstrProfRecord::scaleValueProfData(
736 for (
auto &R : getValueSitesForKind(
ValueKind))
742 assert(
D != 0 &&
"D cannot be 0");
743 for (
auto &Count : this->
Counts) {
750 scaleValueProfData(
Kind,
N,
D, Warn);
759 if (
ValueKind == IPVK_IndirectCallTarget)
771 std::vector<InstrProfValueSiteRecord> &ValueSites =
774 ValueSites.emplace_back();
776 ValueSites.emplace_back(VData, VData +
N);
779 #define INSTR_PROF_COMMON_API_IMPL
793 ->getNumValueSites(VKind);
798 ->getNumValueData(VKind);
804 ->getNumValueDataForSite(VK,
S);
814 (ValueProfData *)(
new (::
operator new(TotalSizeInBytes)) ValueProfData());
815 memset(VD, 0, TotalSizeInBytes);
833 return getValueProfDataSize(&Closure);
837 std::unique_ptr<ValueProfData>
841 std::unique_ptr<ValueProfData> VPD(
850 InstrProfValueData *ValueData = getValueProfRecordValueData(
this);
851 for (
uint64_t VSite = 0; VSite < NumValueSites; ++VSite) {
852 uint8_t ValueDataCount = this->SiteCountArray[VSite];
853 Record.addValueData(
Kind, VSite, ValueData, ValueDataCount, SymTab);
854 ValueData += ValueDataCount;
869 sys::swapByteOrder<uint32_t>(NumValueSites);
870 sys::swapByteOrder<uint32_t>(
Kind);
872 uint32_t ND = getValueProfRecordNumValueData(
this);
873 InstrProfValueData *VD = getValueProfRecordValueData(
this);
877 sys::swapByteOrder<uint64_t>(VD[
I].
Value);
878 sys::swapByteOrder<uint64_t>(VD[
I].Count);
881 sys::swapByteOrder<uint32_t>(NumValueSites);
882 sys::swapByteOrder<uint32_t>(
Kind);
888 if (NumValueKinds == 0)
891 ValueProfRecord *VR = getFirstValueProfRecord(
this);
892 for (
uint32_t K = 0; K < NumValueKinds; K++) {
893 VR->deserializeTo(
Record, SymTab);
894 VR = getValueProfRecordNext(VR);
903 return endian::readNext<T, little, unaligned>(
D);
905 return endian::readNext<T, big, unaligned>(
D);
909 return std::unique_ptr<ValueProfData>(
new (::
operator new(TotalSize))
913 Error ValueProfData::checkIntegrity() {
914 if (NumValueKinds > IPVK_Last + 1)
915 return make_error<InstrProfError>(
919 return make_error<InstrProfError>(
922 ValueProfRecord *VR = getFirstValueProfRecord(
this);
923 for (
uint32_t K = 0; K < this->NumValueKinds; K++) {
924 if (VR->Kind > IPVK_Last)
926 "value kind is invalid");
927 VR = getValueProfRecordNext(VR);
928 if ((
char *)VR - (
char *)
this > (
ptrdiff_t)TotalSize)
929 return make_error<InstrProfError>(
931 "value profile address is greater than total size");
937 ValueProfData::getValueProfData(
const unsigned char *
D,
938 const unsigned char *
const BufferEnd,
942 if (
D +
sizeof(ValueProfData) > BufferEnd)
945 const unsigned char *Header =
D;
947 if (
D + TotalSize > BufferEnd)
951 memcpy(VPD.get(),
D, TotalSize);
955 Error E = VPD->checkIntegrity();
968 sys::swapByteOrder<uint32_t>(TotalSize);
969 sys::swapByteOrder<uint32_t>(NumValueKinds);
971 ValueProfRecord *VR = getFirstValueProfRecord(
this);
972 for (
uint32_t K = 0; K < NumValueKinds; K++) {
974 VR = getValueProfRecordNext(VR);
984 ValueProfRecord *VR = getFirstValueProfRecord(
this);
985 for (
uint32_t K = 0; K < NumValueKinds; K++) {
986 ValueProfRecord *NVR = getValueProfRecordNext(VR);
990 sys::swapByteOrder<uint32_t>(TotalSize);
991 sys::swapByteOrder<uint32_t>(NumValueKinds);
1003 std::unique_ptr<InstrProfValueData[]> VD =
1028 for (
auto &VD : VDs) {
1042 InstrProfValueData ValueData[],
1044 bool GetNoICPValue) {
1059 if (!
Tag->getString().equals(
"VP"))
1075 ActualNumValueData = 0;
1077 for (
unsigned I = 3;
I < NOps;
I += 2) {
1078 if (ActualNumValueData >= MaxNumValueData)
1082 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(
I + 1));
1083 if (!
Value || !Count)
1088 ValueData[ActualNumValueData].Value =
Value->getZExtValue();
1089 ValueData[ActualNumValueData].Count = CntValue;
1090 ActualNumValueData++;
1101 if (PGOFuncName ==
F.getName())
1139 M->getNamedGlobal(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
1140 if (!IRInstrVar || IRInstrVar->hasLocalLinkage())
1145 if (IRInstrVar->isDeclaration())
1149 if (!IRInstrVar->hasInitializer())
1152 auto *InitVal = dyn_cast_or_null<ConstantInt>(IRInstrVar->getInitializer());
1155 return (InitVal->getZExtValue() & VARIANT_MASK_IR_PROF) != 0;
1160 if (
F.getName().empty())
1166 if (CheckAddressTaken &&
F.hasAddressTaken())
1174 if (!
F.hasComdat()) {
1183 if (InstrProfileOutput.
empty())
1189 ProfileNameConst, INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR));
1190 Triple TT(
M.getTargetTriple());
1191 if (TT.supportsCOMDAT()) {
1193 ProfileNameVar->
setComdat(
M.getOrInsertComdat(
1194 StringRef(INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR))));
1199 const std::string &TestFilename,
1201 auto getProfileSum = [IsCS](
const std::string &Filename,
1204 if (
Error E = ReaderOrErr.takeError()) {
1207 auto Reader =
std::move(ReaderOrErr.get());
1208 Reader->accumulateCounts(Sum, IsCS);
1226 for (
unsigned I = 0;
I < IPVK_Last - IPVK_First + 1;
I++) {
1236 for (
unsigned I = 0;
I < IPVK_Last - IPVK_First + 1;
I++) {
1246 const char *EntryName =
1249 OS <<
"Profile overlap infomation for base_profile: " << *
BaseFilename
1250 <<
" and test_profile: " << *
TestFilename <<
"\nProgram level:\n";
1252 OS <<
"Function level:\n"
1261 OS <<
" # of " << EntryName
1267 OS <<
" Mismatched count percentage (Edge): "
1270 OS <<
" Percentage of Edge profile only in test_profile: "
1277 for (
unsigned I = 0;
I < IPVK_Last - IPVK_First + 1;
I++) {
1280 char ProfileKindName[20];
1282 case IPVK_IndirectCallTarget:
1283 strncpy(ProfileKindName,
"IndirectCall", 19);
1285 case IPVK_MemOPSize:
1286 strncpy(ProfileKindName,
"MemOP", 19);
1289 snprintf(ProfileKindName, 19,
"VP[%d]",
I);
1292 OS <<
" " << ProfileKindName
1296 OS <<
" Mismatched count percentage (" << ProfileKindName
1299 OS <<
" Percentage of " << ProfileKindName
1300 <<
" profile only in test_profile: "
1302 OS <<
" " << ProfileKindName
1305 <<
" " << ProfileKindName
1311 namespace IndexedInstrProf {
1313 template <
typename T1,
typename T2>
1320 return *
reinterpret_cast<const uint64_t *
>(Buffer + Offset);
1325 return endian::byte_swap<uint64_t, little>(
Version);
1330 static_assert(std::is_standard_layout<Header>::value,
1331 "The header should be standard layout type since we use offset "
1332 "of fields to read.");
1343 if (GET_VERSION(
H.formatVersion()) >
1347 switch (GET_VERSION(
H.formatVersion())) {
1352 "Please update the reading code below if a new field has been added, "
1353 "if not add a case statement to fall through to the latest version.");
1371 "Please update the size computation below if a new field has "
1372 "been added to the header, if not add a case statement to "
1373 "fall through to the latest version.");
std::enable_if_t< std::is_unsigned< T >::value, T > SaturatingMultiply(T X, T Y, bool *ResultOverflowed=nullptr)
Multiply two unsigned integers, X and Y, of type T.
void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
static double score(uint64_t Val1, uint64_t Val2, double Sum1, double Sum2)
static std::unique_ptr< ValueProfData > allocValueProfData(uint32_t TotalSize)
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void setComdat(Comdat *C)
This is an optimization pass for GlobalISel generic memory operations.
ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
std::string message() const override
Return the error message as a string.
uint32_t getNumValueKindsInstrProf(const void *Record)
ValueProfRecordClosure Interface implementation for InstrProfRecord class.
@ HiddenVisibility
The GV is hidden.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
constexpr size_t offsetOf(T1 T2::*Member)
A raw_ostream that writes to an std::string.
std::unique_ptr< InstrProfValueData[]> getValueForSite(uint32_t ValueKind, uint32_t Site, uint64_t *TotalC=nullptr) const
Return the array of profiled values at Site.
bool needsComdatForCounter(const Function &F, const Module &M)
Check if we can use Comdat for profile variables.
StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static bool isLocalLinkage(LinkageTypes Linkage)
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.
Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize)
Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
void dump(raw_fd_ostream &OS) const
static ErrorSuccess success()
Create a success value.
StringRef getInstrProfNameSeparator()
Return the marker used to separate PGO names during serialization.
void getValueForSiteInstrProf(const void *R, InstrProfValueData *Dst, uint32_t K, uint32_t S)
Triple - Helper class for working with autoconf configuration names.
GlobalVariable * createPGOFuncNameVar(Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
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."))
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).
void overlap(InstrProfRecord &Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff)
Compute the overlap b/w this IntrprofRecord and Other.
@ value_site_count_mismatch
DiagnosticInfoOptimizationBase::Argument NV
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Tagged union holding either a T or a Error.
LinkageTypes
An enumeration for the kinds of linkage for global values.
std::string getPGOFuncNameVarName(StringRef FuncName, GlobalValue::LinkageTypes Linkage)
Return the name of the global variable used to store a function name in PGO instrumentation.
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
#define LLVM_ATTRIBUTE_UNUSED
bool isDiscardableIfUnused() const
void consumeError(Error Err)
Consume a Error without doing anything.
static IntegerType * getInt32Ty(LLVMContext &C)
bool empty() const
empty - Check if the array is empty.
Profiling information for a single function.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void merge(InstrProfValueSiteRecord &Input, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge data from another InstrProfValueSiteRecord Optionally scale merged counts by Weight.
unsigned getNumOperands() const
Return number of MDNode operands.
@ unexpected_debug_info_for_correlation
const std::string * TestFilename
static std::string getInstrProfErrString(instrprof_error Err, const std::string &ErrMsg="")
This is the shared class of boolean and integer constants.
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.
uint32_t getNumValueDataForSite(uint32_t ValueKind, uint32_t Site) const
Return the number of value data collected for ValueKind at profiling site: Site.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static constexpr int BestSizeCompression
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
void compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, int Level=DefaultCompression)
(vector float) vec_cmpeq(*A, *B) C
static ValueProfRecordClosure InstrProfRecordClosure
bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
uint32_t getNumValueSites(uint32_t ValueKind) const
Return the number of instrumented sites for ValueKind.
ValueProfData * allocValueProfDataInstrProf(size_t TotalSizeInBytes)
bool supportsCOMDAT() const
Tests whether the target supports comdat.
static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix)
static T swapToHostOrder(const unsigned char *&D, support::endianness Orig)
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.
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."))
@ InternalLinkage
Rename collisions when linking (static functions).
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
An efficient, type-erasing, non-owning reference to a callable.
const MDOperand & getOperand(unsigned I) const
MDString * createString(StringRef Str)
Return the given string as metadata.
support::endianness getHostEndianness()
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
void addError(instrprof_error IE)
Track a soft error (IE) and increment its associated counter.
uint32_t getNumValueSitesInstrProf(const void *Record, uint32_t VKind)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
std::enable_if_t< std::is_unsigned< T >::value, T > 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.
initializer< Ty > init(const Ty &Val)
void setLinkage(LinkageTypes LT)
static MDString * get(LLVMContext &Context, StringRef Str)
message(STATUS "Targeting ${t}") add_subdirectory($
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
A Module instance is used to store all the information related to an LLVM module.
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...
uint32_t getNumValueDataInstrProf(const void *Record, uint32_t VKind)
const unsigned char * bytes_begin() const
uint64_t getFunctionHashFromAddress(uint64_t Address)
Return a function's hash, or 0, if the function isn't in this SymTab.
void accumulateCounts(CountSumOrPercent &Sum) const
Compute the sums of all counts and store in Sum.
void addOneUnique(const CountSumOrPercent &UniqueFunc)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
static ManagedStatic< InstrProfErrorCategoryType > ErrorCategory
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ AvailableExternallyLinkage
Available for inspection, not emission.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::list< InstrProfValueData > ValueData
Value profiling data pairs at a given value site.
A raw_ostream that writes to a file descriptor.
const std::error_category & instrprof_category()
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...
const CustomOperand< const MCSubtargetInfo & > Msg[]
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
void merge(InstrProfRecord &Other, uint64_t Weight, function_ref< void(instrprof_error)> Warn)
Merge the counts in Other into this one.
cl::opt< bool > DoInstrProfNameCompression
void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap of value profile counts.
Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab)
NameStrings is a string composed of one of more sub-strings encoded in the format described above.
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
static IntegerType * getInt64Ty(LLVMContext &C)
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap)
Compute the overlap b/w this record and Input record.
Lightweight error class with error context and mandatory checking.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
static Expected< std::unique_ptr< InstrProfReader > > create(const Twine &Path, const InstrProfCorrelator *Correlator=nullptr)
Factory method to create an appropriately typed reader for the given instrprof file.
const uint64_t NOMORE_ICP_MAGICNUM
Magic number in the value profile metadata showing a target has been promoted for the instruction and...
CountSumOrPercent Overlap
uint32_t getNumValueDataForSiteInstrProf(const void *R, uint32_t VK, uint32_t S)
CountSumOrPercent Mismatch
StringRef getPGOFuncNameMetadataName()
void addValueData(uint32_t ValueKind, uint32_t Site, InstrProfValueData *VData, uint32_t N, InstrProfSymtab *SymTab)
Add ValueData for ValueKind at value Site.
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
@ ExternalLinkage
Externally visible function.
bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
Error addFuncName(StringRef FuncName)
Update the symtab by adding FuncName to the table.
@ PrivateLinkage
Like Internal, but omit from symbol table.
const std::string * BaseFilename
@ unable_to_correlate_profile
size_t size() const
size - Get the array size.
Reimplement select in terms of SEL *We would really like to support but we need to prove that the add doesn t need to overflow between the two bit chunks *Implement pre post increment support(e.g. PR935) *Implement smarter const ant generation for binops with large immediates. A few ARMv6T2 ops should be pattern matched
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
void sortByTargetValues()
Sort ValueData ascending by Value.
double ValueCounts[IPVK_Last - IPVK_First+1]
StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName="<unknown>")
Given a PGO function name, remove the filename prefix and return the original (static) function name.
Error accumulateCounts(const std::string &BaseFilename, const std::string &TestFilename, bool IsCS)
static uint64_t read(const unsigned char *Buffer, size_t Offset)
bool getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, InstrProfValueData ValueData[], uint32_t &ActualNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst which is annotated with value profile meta data.
@ ExternalWeakLinkage
ExternalWeak linkage description.
static ManagedStatic< _object_error_category > error_category
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
std::string & str()
Returns the string's reference.
LLVM Value Representation.
void addOneMismatch(const CountSumOrPercent &MismatchFunc)
std::vector< uint64_t > Counts
@ missing_debug_info_for_correlation
Optional< std::vector< StOtherPiece > > Other
MDNode * getPGOFuncNameMetadata(const Function &F)
Return the PGOFuncName meta data associated with a function.
const unsigned char * bytes_end() const
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).