42#define DEBUG_TYPE "memprof"
54 "memprof-match-hot-cold-new",
56 "Match allocation profiles onto existing hot/cold operator new calls"),
61 cl::desc(
"Print matching stats for each allocation "
62 "context in this module's profiles"),
66 "memprof-print-matched-alloc-stack",
67 cl::desc(
"Print full stack context for matched "
68 "allocations with -memprof-print-match-info."),
73 cl::desc(
"Print function GUIDs computed for matching"),
78 cl::desc(
"Salvage stale MemProf profile"),
82 "memprof-attach-calleeguids",
84 "Attach calleeguids as value profile metadata for indirect calls."),
89 cl::desc(
"Min percent of cold bytes matched to hint allocation cold"));
93 cl::desc(
"If true, annotate the static data section prefix"));
99 "memprof-annotate-string-literal-section-prefix",
cl::init(
false),
101 cl::desc(
"If true, annotate the string literal data section prefix"));
104STATISTIC(NumOfMemProfMissing,
"Number of functions without memory profile.");
106 "Number of functions having mismatched memory profile hash.");
107STATISTIC(NumOfMemProfFunc,
"Number of functions having valid memory profile.");
109 "Number of alloc contexts in memory profile.");
111 "Number of callsites in memory profile.");
113 "Number of matched memory profile alloc contexts.");
115 "Number of matched memory profile allocs.");
117 "Number of matched memory profile callsites.");
119 "Number of global vars annotated with 'hot' section prefix.");
121 "Number of global vars annotated with 'unlikely' section prefix.");
123 "Number of global vars with unknown hotness (no section prefix).");
125 "Number of global vars with user-specified section (not annotated).");
130 I.setMetadata(LLVMContext::MD_callsite,
141 std::memcpy(&Id, Hash.data(),
sizeof(Hash));
159 for (
const auto &StackFrame :
AllocInfo->CallStack)
162 std::vector<ContextTotalSize> ContextSizeInfo;
164 auto TotalSize =
AllocInfo->Info.getTotalSize();
167 ContextSizeInfo.push_back({FullStackId, TotalSize});
179 return ProfileCallStack.
size() >= InlinedCallStack.
size() &&
182 return computeStackId(F) == StackId;
195 case LibFunc_ZnwmRKSt9nothrow_t:
196 case LibFunc_ZnwmSt11align_val_t:
197 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
199 case LibFunc_ZnamRKSt9nothrow_t:
200 case LibFunc_ZnamSt11align_val_t:
201 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
202 case LibFunc_size_returning_new:
203 case LibFunc_size_returning_new_aligned:
205 case LibFunc_Znwm12__hot_cold_t:
206 case LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t:
207 case LibFunc_ZnwmSt11align_val_t12__hot_cold_t:
208 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t:
209 case LibFunc_Znam12__hot_cold_t:
210 case LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t:
211 case LibFunc_ZnamSt11align_val_t12__hot_cold_t:
212 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t:
213 case LibFunc_size_returning_new_hot_cold:
214 case LibFunc_size_returning_new_aligned_hot_cold:
224 "Should not handle AnnotationOK here");
228 ++NumOfMemProfExplicitSectionGlobalVars;
229 Reason.
append(
"explicit section name");
232 Reason.
append(
"linker declaration");
235 Reason.
append(
"name starts with `llvm.`");
246static std::optional<uint64_t>
287 return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
292 if (
F.isDeclaration())
301 auto *CalledFunction = CB->getCalledFunction();
303 if (!CalledFunction || CalledFunction->isIntrinsic())
306 StringRef CalleeName = CalledFunction->getName();
314 DIL = DIL->getInlinedAt()) {
315 StringRef CallerName = DIL->getSubprogramLinkageName();
317 "Be sure to enable -fdebug-info-for-profiling");
327 }
else if (!IsPresentInProfile(CalleeGUID)) {
339 Calls[CallerGUID].emplace_back(
Loc, CalleeGUID);
340 CalleeName = CallerName;
348 for (
auto &[CallerGUID, CallList] : Calls) {
365 return CallsFromProfile.
contains(GUID);
369 for (
const auto &[CallerGUID, IRAnchors] : CallsFromIR) {
370 auto It = CallsFromProfile.
find(CallerGUID);
371 if (It == CallsFromProfile.
end())
373 const auto &ProfileAnchors = It->second;
377 ProfileAnchors, IRAnchors, std::equal_to<GlobalValue::GUID>(),
379 [[maybe_unused]]
bool Inserted =
380 UndriftMaps.
try_emplace(CallerGUID, std::move(Matchings)).second;
395 auto UndriftCallStack = [&](std::vector<Frame> &
CallStack) {
397 auto I = UndriftMaps.
find(
F.Function);
398 if (
I == UndriftMaps.
end())
401 if (J ==
I->second.end())
403 auto &NewLoc = J->second;
404 F.LineOffset = NewLoc.LineOffset;
405 F.Column = NewLoc.Column;
410 UndriftCallStack(AS.CallStack);
413 UndriftCallStack(CS.Frames);
428 if (
I.getMetadata(LLVMContext::MD_prof)) {
432 UINT32_MAX, TotalCount);
436 const size_t OriginalSize = VDs.
size();
442 VDs, [](
const InstrProfValueData &Entry) {
return Entry.Value; }));
447 for (
auto G : CalleeGuids) {
448 if (!ExistingValues.insert(
G).second)
450 InstrProfValueData NewEntry;
457 TotalCount += NewEntry.Count;
463 if (VDs.
size() == OriginalSize)
467 I.setMetadata(LLVMContext::MD_prof,
nullptr);
478 const std::set<const AllocationInfo *> &AllocInfoSet,
479 std::map<uint64_t, AllocMatchInfo> &FullStackIdToAllocMatchInfo) {
486 auto [It, Inserted] =
492 auto CurSize = It->second->Info.getTotalSize();
493 auto NewSize =
AllocInfo->Info.getTotalSize();
494 if ((CurSize > NewSize) ||
495 (CurSize == NewSize &&
506 for (
auto &[FullStackId,
AllocInfo] : UniqueFullContextIdAllocInfo) {
512 NumOfMemProfMatchedAllocContexts++;
514 TotalSize +=
AllocInfo->Info.getTotalSize();
516 TotalColdSize +=
AllocInfo->Info.getTotalSize();
521 auto [Iter, Inserted] = FullStackIdToAllocMatchInfo.try_emplace(
525 Iter->second.MatchedFramesSet.insert(InlinedCallStack.
size());
527 Iter->second.CallStack.insert(Iter->second.CallStack.begin(),
533 <<
ore::NV(
"AllocationCall", CI) <<
" in function "
535 <<
" matched alloc context with alloc type "
538 <<
" full context id " <<
ore::NV(
"Context", FullStackId)
539 <<
" frame count " <<
ore::NV(
"Frames", InlinedCallStack.
size()));
554 if (!AllocTrie.
empty()) {
555 NumOfMemProfMatchedAllocs++;
559 assert(MemprofMDAttached ==
I.hasMetadata(LLVMContext::MD_memprof));
560 if (MemprofMDAttached) {
585 const std::vector<CallSiteEntry> &CallSiteEntries,
587 std::set<std::vector<uint64_t>> &MatchedCallSites,
589 auto &Ctx = M.getContext();
595 bool CallsiteMDAdded =
false;
601 NumOfMemProfMatchedCallSites++;
604 if (!CallsiteMDAdded) {
611 MatchedCallSites.insert(std::move(
CallStack));
614 <<
ore::NV(
"CallSite", &
I) <<
" in function "
615 <<
ore::NV(
"Caller",
I.getFunction())
616 <<
" matched callsite with frame count "
622 CallsiteMDAdded =
true;
625 assert(!CalledFunction &&
"Didn't expect direct call");
639 std::map<uint64_t, AllocMatchInfo> &FullStackIdToAllocMatchInfo,
640 std::set<std::vector<uint64_t>> &MatchedCallSites,
643 auto &Ctx = M.getContext();
651 auto FuncName =
F.getName();
654 errs() <<
"MemProf: Function GUID " << FuncGUID <<
" is " << FuncName
656 std::optional<memprof::MemProfRecord> MemProfRec;
657 auto Err =
MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
660 auto Err = IPE.
get();
661 bool SkipWarning =
false;
662 LLVM_DEBUG(
dbgs() <<
"Error in reading profile for Func " << FuncName
665 NumOfMemProfMissing++;
669 NumOfMemProfMismatch++;
675 LLVM_DEBUG(
dbgs() <<
"hash mismatch (skip=" << SkipWarning <<
")");
681 std::string Msg = (IPE.
message() +
Twine(
" ") +
F.getName().str() +
682 Twine(
" Hash = ") + std::to_string(FuncGUID))
702 bool ProfileHasColumns =
false;
706 std::map<uint64_t, std::set<const AllocationInfo *>> LocHashToAllocInfo;
710 std::map<uint64_t, std::vector<CallSiteEntry>> LocHashToCallSites;
711 for (
auto &AI : MemProfRec->AllocSites) {
712 NumOfMemProfAllocContextProfiles++;
717 LocHashToAllocInfo[StackId].insert(&AI);
718 ProfileHasColumns |= AI.CallStack[0].Column;
720 for (
auto &CS : MemProfRec->CallSites) {
721 NumOfMemProfCallSiteProfiles++;
725 for (
auto &StackFrame : CS.Frames) {
732 LocHashToCallSites[StackId].push_back(
733 {FrameSlice, (Idx == 1 ? CS.CalleeGuids
735 CS.Frames[Idx - 2].Function))});
737 ProfileHasColumns |= StackFrame.Column;
739 if (StackFrame.Function == FuncGUID)
742 assert(Idx <= CS.Frames.size() && CS.Frames[Idx - 1].Function == FuncGUID);
746 return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
754 if (
I.isDebugOrPseudoInst())
761 auto *CalledFunction = CI->getCalledFunction();
762 if (CalledFunction && CalledFunction->isIntrinsic())
768 bool LeafFound =
false;
774 auto AllocInfoIter = LocHashToAllocInfo.
end();
775 auto CallSitesIter = LocHashToCallSites.end();
776 for (
const DILocation *DIL =
I.getDebugLoc(); DIL !=
nullptr;
777 DIL = DIL->getInlinedAt()) {
780 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
782 Name = DIL->getScope()->getSubprogram()->getName();
785 ProfileHasColumns ? DIL->getColumn() : 0);
791 AllocInfoIter = LocHashToAllocInfo.find(StackId);
792 CallSitesIter = LocHashToCallSites.find(StackId);
793 if (AllocInfoIter != LocHashToAllocInfo.end() ||
794 CallSitesIter != LocHashToCallSites.end())
808 if (AllocInfoIter != LocHashToAllocInfo.end() &&
812 AllocInfoIter->second, FullStackIdToAllocMatchInfo);
813 else if (CallSitesIter != LocHashToCallSites.end())
818 CallSitesIter->second, M, MatchedCallSites, ORE);
825 : MemoryProfileFileName(MemoryProfileFile), FS(FS) {
833 if (M.empty() && M.globals().empty())
837 auto &Ctx = M.getContext();
839 if (
Error E = ReaderOrErr.takeError()) {
848 std::move(ReaderOrErr.get());
851 MemoryProfileFileName.data(),
StringRef(
"Cannot get MemProfReader")));
857 "Not a memory profile"));
862 annotateGlobalVariables(M,
MemProfReader->getDataAccessProfileData());
880 std::map<uint64_t, AllocMatchInfo> FullStackIdToAllocMatchInfo;
884 std::set<std::vector<uint64_t>> MatchedCallSites;
888 MaxColdSize = MemProfSum->getMaxColdTotalSize();
891 if (
F.isDeclaration())
897 MatchedCallSites, UndriftMaps, ORE, MaxColdSize);
901 for (
const auto &[Id, Info] : FullStackIdToAllocMatchInfo) {
902 for (
auto Frames : Info.MatchedFramesSet) {
907 <<
" context with id " << Id <<
" has total profiled size "
908 << Info.TotalSize <<
" is matched with " << Frames <<
" frames";
910 errs() <<
" and call stack";
911 for (
auto &
F : Info.CallStack)
918 for (
const auto &
CallStack : MatchedCallSites) {
919 errs() <<
"MemProf callsite match for inline call stack";
921 errs() <<
" " << StackId;
929bool MemProfUsePass::annotateGlobalVariables(
934 if (!DataAccessProf) {
949 assert(!GVar.getSectionPrefix().has_value() &&
950 "GVar shouldn't have section prefix yet");
957 StringRef
Name = GVar.getName();
962 if (
Name.starts_with(
".str"))
965 if (
Name.starts_with(
".str")) {
968 LLVM_DEBUG(
dbgs() <<
"Cannot compute content hash for string literal "
977 std::optional<DataAccessProfRecord>
Record =
985 if (Record &&
Record->AccessCount > 0) {
986 ++NumOfMemProfHotGlobalVars;
987 Changed |= GVar.setSectionPrefix(
"hot");
989 <<
" is annotated as hot\n");
991 ++NumOfMemProfColdGlobalVars;
992 Changed |= GVar.setSectionPrefix(
"unlikely");
995 <<
" is annotated as unlikely\n");
997 ++NumOfMemProfUnknownGlobalVars;
998 LLVM_DEBUG(
dbgs() <<
"Global variable " << Name <<
" is not annotated\n");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
static std::optional< uint64_t > getStringContentHash(const GlobalVariable &GVar)
static void addCallsiteMetadata(Instruction &I, ArrayRef< uint64_t > InlinedCallStack, LLVMContext &Ctx)
static bool isAllocationWithHotColdVariant(const Function *Callee, const TargetLibraryInfo &TLI)
static cl::opt< bool > ClMemProfAttachCalleeGuids("memprof-attach-calleeguids", cl::desc("Attach calleeguids as value profile metadata for indirect calls."), cl::init(true), cl::Hidden)
static void HandleUnsupportedAnnotationKinds(GlobalVariable &GVar, AnnotationKind Kind)
static void undriftMemProfRecord(const DenseMap< uint64_t, LocToLocMap > &UndriftMaps, memprof::MemProfRecord &MemProfRec)
static uint64_t computeStackId(GlobalValue::GUID Function, uint32_t LineOffset, uint32_t Column)
static cl::opt< bool > PrintMatchedAllocStack("memprof-print-matched-alloc-stack", cl::desc("Print full stack context for matched " "allocations with -memprof-print-match-info."), cl::Hidden, cl::init(false))
static void handleCallSite(Instruction &I, const Function *CalledFunction, ArrayRef< uint64_t > InlinedCallStack, const std::vector< CallSiteEntry > &CallSiteEntries, Module &M, std::set< std::vector< uint64_t > > &MatchedCallSites, OptimizationRemarkEmitter &ORE)
static cl::opt< bool > ClPrintMemProfMatchInfo("memprof-print-match-info", cl::desc("Print matching stats for each allocation " "context in this module's profiles"), cl::Hidden, cl::init(false))
static void addVPMetadata(Module &M, Instruction &I, ArrayRef< GlobalValue::GUID > CalleeGuids)
static cl::opt< bool > PrintFunctionGuids("memprof-print-function-guids", cl::desc("Print function GUIDs computed for matching"), cl::Hidden, cl::init(false))
static cl::opt< bool > AnnotateStaticDataSectionPrefix("memprof-annotate-static-data-prefix", cl::init(false), cl::Hidden, cl::desc("If true, annotate the static data section prefix"))
static void handleAllocSite(Instruction &I, CallBase *CI, ArrayRef< uint64_t > InlinedCallStack, LLVMContext &Ctx, OptimizationRemarkEmitter &ORE, uint64_t MaxColdSize, const std::set< const AllocationInfo * > &AllocInfoSet, std::map< uint64_t, AllocMatchInfo > &FullStackIdToAllocMatchInfo)
static cl::opt< bool > SalvageStaleProfile("memprof-salvage-stale-profile", cl::desc("Salvage stale MemProf profile"), cl::init(false), cl::Hidden)
static cl::opt< unsigned > MinMatchedColdBytePercent("memprof-matching-cold-threshold", cl::init(100), cl::Hidden, cl::desc("Min percent of cold bytes matched to hint allocation cold"))
static void readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI, std::map< uint64_t, AllocMatchInfo > &FullStackIdToAllocMatchInfo, std::set< std::vector< uint64_t > > &MatchedCallSites, DenseMap< uint64_t, LocToLocMap > &UndriftMaps, OptimizationRemarkEmitter &ORE, uint64_t MaxColdSize)
static cl::opt< bool > AnnotateStringLiteralSectionPrefix("memprof-annotate-string-literal-section-prefix", cl::init(false), cl::Hidden, cl::desc("If true, annotate the string literal data section prefix"))
static cl::opt< bool > ClMemProfMatchHotColdNew("memprof-match-hot-cold-new", cl::desc("Match allocation profiles onto existing hot/cold operator new calls"), cl::Hidden, cl::init(false))
static AllocationType addCallStack(CallStackTrie &AllocTrie, const AllocationInfo *AllocInfo, uint64_t FullStackId)
static bool stackFrameIncludesInlinedCallStack(ArrayRef< Frame > ProfileCallStack, ArrayRef< uint64_t > InlinedCallStack)
FunctionAnalysisManager FAM
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Defines the virtual file system interface vfs::FileSystem.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
Diagnostic information for the PGO profiler.
Base class for error info classes.
virtual std::string message() const
Return the error message as a string.
Lightweight error class with error context and mandatory checking.
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
@ AvailableExternallyLinkage
Available for inspection, not emission.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
HashResultTy< HasherT_ > final()
Forward to HasherT::final() if available.
Interface to help hash various types through a hasher type.
std::enable_if_t< hashbuilder_detail::IsHashableData< T >::value, HashBuilder & > add(T Value)
Implement hashing for hashable data types, e.g. integral or enum values.
Reader for the indexed binary instrprof format.
static Expected< std::unique_ptr< IndexedInstrProfReader > > create(const Twine &Path, vfs::FileSystem &FS, const Twine &RemappingPath="")
Factory method to create an indexed reader.
instrprof_error get() const
std::string message() const override
Return the error message as a string.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an important class for using LLVM in a threaded context.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI MemProfUsePass(std::string MemoryProfileFile, IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr)
A Module instance is used to store all the information related to an LLVM module.
@ Warning
Emits a warning if two values disagree.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A vector that has set insertion semantics.
ArrayRef< value_type > getArrayRef() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
An efficient, type-erasing, non-owning reference to a callable.
Class to build a trie of call stack contexts for a particular profiled allocation call,...
LLVM_ABI void addCallStack(AllocationType AllocType, ArrayRef< uint64_t > StackIds, std::vector< ContextTotalSize > ContextSizeInfo={})
Add a call stack context with the given allocation type to the Trie.
LLVM_ABI void addSingleAllocTypeAttribute(CallBase *CI, AllocationType AT, StringRef Descriptor)
Add an attribute for the given allocation type to the call instruction.
LLVM_ABI bool buildAndAttachMIBMetadata(CallBase *CI)
Build and attach the minimal necessary MIB metadata.
Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...
Encapsulates the data access profile data and the methods to operate on it.
LLVM_ABI std::optional< DataAccessProfRecord > getProfileRecord(const SymbolHandleRef SymID) const
Returns a profile record for SymbolID, or std::nullopt if there isn't a record.
LLVM_ABI bool isKnownColdSymbol(const SymbolHandleRef SymID) const
Returns true if SymID is seen in profiled binaries and cold.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
LLVM_ABI DenseMap< uint64_t, LocToLocMap > computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
LLVM_ABI MDNode * buildCallstackMetadata(ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)
Build callstack metadata from the provided list of call stack ids.
LLVM_ABI AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)
Return the allocation type for a given set of memory profile values.
LLVM_ABI bool recordContextSizeInfoForAnalysis()
Whether we need to record the context size info in the alloc trie used to build metadata.
std::unordered_map< LineLocation, LineLocation, LineLocationHash > LocToLocMap
LLVM_ABI uint64_t computeFullStackId(ArrayRef< Frame > CallStack)
Helper to generate a single hash id for a given callstack, used for emitting matching statistics and ...
std::variant< StringRef, uint64_t > SymbolHandleRef
LLVM_ABI DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > extractCallsFromIR(Module &M, const TargetLibraryInfo &TLI, function_ref< bool(uint64_t)> IsPresentInProfile=[](uint64_t) { return true;})
AnnotationKind getAnnotationKind(const GlobalVariable &GV)
Returns the annotation kind of the global variable GV.
LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName)
LLVM_ABI std::string getAllocTypeAttributeString(AllocationType Type)
Returns the string to use in attributes with the given type.
DiagnosticInfoOptimizationBase::Argument NV
uint64_t MD5Hash(const FunctionId &Obj)
LLVM_ABI IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
std::array< uint8_t, NumBytes > BLAKE3Result
The constant LLVM_BLAKE3_OUT_LEN provides the default output length, 32 bytes, which is recommended f...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
constexpr from_range_t from_range
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
cl::opt< bool > PGOWarnMissing
auto unique(Range &&R, Predicate P)
auto map_range(ContainerTy &&C, FuncTy F)
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...
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
cl::opt< bool > NoPGOWarnMismatch
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
cl::opt< bool > SalvageStaleProfile("salvage-stale-profile", cl::Hidden, cl::init(false), cl::desc("Salvage stale profile by fuzzy matching and use the remapped " "location for sample profile query."))
void longestCommonSequence(AnchorList AnchorList1, AnchorList AnchorList2, llvm::function_ref< bool(const Function &, const Function &)> FunctionMatchesProfile, llvm::function_ref< void(Loc, Loc)> InsertMatching)
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
cl::opt< bool > NoPGOWarnMismatchComdatWeak
std::set< unsigned > MatchedFramesSet
std::vector< Frame > CallStack
AllocMatchInfo(uint64_t TotalSize, AllocationType AllocType)
ArrayRef< GlobalValue::GUID > CalleeGuids
Summary of memprof metadata on allocations.
GlobalValue::GUID Function
llvm::SmallVector< CallSiteInfo > CallSites
llvm::SmallVector< AllocationInfo > AllocSites