45#define DEBUG_TYPE "memprof"
53STATISTIC(NumOfMemProfMissing,
"Number of functions without memory profile.");
55 "Number of functions having mismatched memory profile hash.");
56STATISTIC(NumOfMemProfFunc,
"Number of functions having valid memory profile.");
58 "Number of alloc contexts in memory profile.");
60 "Number of callsites in memory profile.");
62 "Number of matched memory profile alloc contexts.");
64 "Number of matched memory profile allocs.");
66 "Number of matched memory profile callsites.");
68 "Number of global vars annotated with 'hot' section prefix.");
70 "Number of global vars annotated with 'unlikely' section prefix.");
72 "Number of global vars with unknown hotness (no section prefix).");
74 "Number of global vars with user-specified section (not annotated).");
79 I.setMetadata(LLVMContext::MD_callsite,
90 std::memcpy(&Id, Hash.data(),
sizeof(Hash));
102 unsigned Line = DIL->getLine();
103 unsigned SubprogramLine = DIL->getScope()->getSubprogram()->getLine();
104 if (Line < SubprogramLine)
106 return Line - SubprogramLine;
119 for (
const auto &StackFrame :
AllocInfo->CallStack)
122 std::vector<ContextTotalSize> ContextSizeInfo;
124 auto TotalSize =
AllocInfo->Info.getTotalSize();
127 ContextSizeInfo.push_back({FullStackId, TotalSize});
139 return ProfileCallStack.
size() >= InlinedCallStack.
size() &&
142 return computeStackId(F) == StackId;
152 if (Func == NotLibFunc)
156 case LibFunc_ZnwmRKSt9nothrow_t:
157 case LibFunc_ZnwmSt11align_val_t:
158 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
160 case LibFunc_ZnamRKSt9nothrow_t:
161 case LibFunc_ZnamSt11align_val_t:
162 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
163 case LibFunc_size_returning_new:
164 case LibFunc_size_returning_new_aligned:
166 case LibFunc_Znwm12__hot_cold_t:
167 case LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t:
168 case LibFunc_ZnwmSt11align_val_t12__hot_cold_t:
169 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t:
170 case LibFunc_Znam12__hot_cold_t:
171 case LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t:
172 case LibFunc_ZnamSt11align_val_t12__hot_cold_t:
173 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t:
174 case LibFunc_size_returning_new_hot_cold:
175 case LibFunc_size_returning_new_aligned_hot_cold:
176 return Opts.memprof_match_hot_cold_new;
185 "Should not handle AnnotationOK here");
189 ++NumOfMemProfExplicitSectionGlobalVars;
190 Reason.
append(
"explicit section name");
193 Reason.
append(
"linker declaration");
196 Reason.
append(
"name starts with `llvm.`");
207static std::optional<uint64_t>
245 const InstrumentationOptions &Opts =
246 M.getContext().getLibraryOptions().get<InstrumentationOptions>();
250 if (
F.isDeclaration())
259 auto *CalledFunction = CB->getCalledFunction();
261 if (!CalledFunction || CalledFunction->isIntrinsic())
264 StringRef CalleeName = CalledFunction->getName();
273 DIL = DIL->getInlinedAt()) {
274 StringRef CallerName = DIL->getSubprogramLinkageName();
276 "Be sure to enable -fdebug-info-for-profiling");
286 }
else if (!IsPresentInProfile(CalleeGUID)) {
298 Calls[CallerGUID].emplace_back(
Loc, CalleeGUID);
299 CalleeName = CallerName;
307 for (
auto &[CallerGUID, CallList] : Calls) {
324 return CallsFromProfile.
contains(GUID);
328 for (
const auto &[CallerGUID, IRAnchors] : CallsFromIR) {
329 auto It = CallsFromProfile.
find(CallerGUID);
330 if (It == CallsFromProfile.
end())
332 const auto &ProfileAnchors = It->second;
336 ProfileAnchors, IRAnchors, std::equal_to<GlobalValue::GUID>(),
338 [[maybe_unused]]
bool Inserted =
339 UndriftMaps.
try_emplace(CallerGUID, std::move(Matchings)).second;
354 auto UndriftCallStack = [&](std::vector<Frame> &
CallStack) {
356 auto I = UndriftMaps.
find(
F.Function);
357 if (
I == UndriftMaps.
end())
360 if (J ==
I->second.end())
362 auto &NewLoc = J->second;
363 F.LineOffset = NewLoc.LineOffset;
364 F.Column = NewLoc.Column;
369 UndriftCallStack(AS.CallStack);
372 UndriftCallStack(CS.Frames);
379 if (!Opts.memprof_attach_calleeguids || CalleeGuids.
empty())
388 if (
I.getMetadata(LLVMContext::MD_prof)) {
392 UINT32_MAX, TotalCount);
396 const size_t OriginalSize = VDs.
size();
402 VDs, [](
const InstrProfValueData &Entry) {
return Entry.Value; }));
407 for (
auto G : CalleeGuids) {
408 if (!ExistingValues.insert(
G).second)
410 InstrProfValueData NewEntry;
417 TotalCount += NewEntry.Count;
423 if (VDs.
size() == OriginalSize)
427 I.setMetadata(LLVMContext::MD_prof,
nullptr);
439 const std::set<const AllocationInfo *> &AllocInfoSet,
440 std::map<uint64_t, AllocMatchInfo> &FullStackIdToAllocMatchInfo) {
447 auto [It, Inserted] =
453 auto CurSize = It->second->Info.getTotalSize();
454 auto NewSize =
AllocInfo->Info.getTotalSize();
455 if ((CurSize > NewSize) ||
456 (CurSize == NewSize &&
467 for (
auto &[FullStackId,
AllocInfo] : UniqueFullContextIdAllocInfo) {
473 NumOfMemProfMatchedAllocContexts++;
475 TotalSize +=
AllocInfo->Info.getTotalSize();
477 TotalColdSize +=
AllocInfo->Info.getTotalSize();
480 if (Opts.memprof_print_match_info) {
482 auto [Iter, Inserted] = FullStackIdToAllocMatchInfo.try_emplace(
486 Iter->second.MatchedFramesSet.insert(InlinedCallStack.
size());
487 if (Inserted && Opts.memprof_print_matched_alloc_stack)
488 Iter->second.CallStack.insert(Iter->second.CallStack.begin(),
494 <<
ore::NV(
"AllocationCall", CI) <<
" in function "
496 <<
" matched alloc context with alloc type "
499 <<
" full context id " <<
ore::NV(
"Context", FullStackId)
500 <<
" frame count " <<
ore::NV(
"Frames", InlinedCallStack.
size()));
506 if (TotalColdSize < TotalSize && Opts.memprof_matching_cold_threshold < 100 &&
507 TotalColdSize * 100 >= Opts.memprof_matching_cold_threshold * TotalSize) {
515 if (!AllocTrie.
empty()) {
516 NumOfMemProfMatchedAllocs++;
520 assert(MemprofMDAttached ==
I.hasMetadata(LLVMContext::MD_memprof));
521 if (MemprofMDAttached) {
547 const std::vector<CallSiteEntry> &CallSiteEntries,
549 std::set<std::vector<uint64_t>> &MatchedCallSites,
551 auto &Ctx = M.getContext();
557 bool CallsiteMDAdded =
false;
563 NumOfMemProfMatchedCallSites++;
566 if (!CallsiteMDAdded) {
570 if (Opts.memprof_print_match_info) {
573 MatchedCallSites.insert(std::move(
CallStack));
577 <<
ore::NV(
"Caller",
I.getFunction())
578 <<
" matched callsite with frame count "
581 for (
uint64_t StackId : InlinedCallStack)
588 CallsiteMDAdded =
true;
591 assert(!CalledFunction &&
"Didn't expect direct call");
607 bool ProfileHasColumns) {
613 DIL = DIL->getInlinedAt()) {
614 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
616 Name = DIL->getScope()->getSubprogram()->getName();
619 ProfileHasColumns ? DIL->getColumn() : 0);
620 if (SeenFrames.
insert(FrameID).second) {
623 DictOS <<
"frame: " << FrameID <<
" " << Name <<
":" <<
getLineOffset(DIL)
624 <<
":" << (ProfileHasColumns ? DIL->getColumn() : 0);
633 CallStackOS << FrameID;
638 if (SeenStacks.
insert(StackHash).second) {
641 OS <<
"inline call stack: " <<
CallStack;
650 std::map<uint64_t, AllocMatchInfo> &FullStackIdToAllocMatchInfo,
651 std::set<std::vector<uint64_t>> &MatchedCallSites,
655 auto &Ctx = M.getContext();
663 auto FuncName =
F.getName();
665 if (Opts.memprof_print_function_guids)
666 errs() <<
"MemProf: Function GUID " << FuncGUID <<
" is " << FuncName
668 std::optional<memprof::MemProfRecord> MemProfRec;
669 auto Err =
MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
672 auto Err = IPE.
get();
673 bool SkipWarning =
false;
674 LLVM_DEBUG(
dbgs() <<
"Error in reading profile for Func " << FuncName
677 NumOfMemProfMissing++;
678 SkipWarning = !Opts.pgo_warn_missing_function;
681 NumOfMemProfMismatch++;
684 (Opts.no_pgo_warn_mismatch_comdat_weak &&
687 LLVM_DEBUG(
dbgs() <<
"hash mismatch (skip=" << SkipWarning <<
")");
694 Twine(
" Hash = ") + std::to_string(FuncGUID))
707 if (Opts.memprof_salvage_stale_profile)
714 bool ProfileHasColumns =
false;
718 std::map<uint64_t, std::set<const AllocationInfo *>> LocHashToAllocInfo;
722 std::map<uint64_t, std::vector<CallSiteEntry>> LocHashToCallSites;
723 for (
auto &AI : MemProfRec->AllocSites) {
724 NumOfMemProfAllocContextProfiles++;
729 LocHashToAllocInfo[StackId].insert(&AI);
730 ProfileHasColumns |= AI.CallStack[0].Column;
732 for (
auto &CS : MemProfRec->CallSites) {
733 NumOfMemProfCallSiteProfiles++;
737 for (
auto &StackFrame : CS.Frames) {
744 LocHashToCallSites[StackId].push_back(
745 {FrameSlice, (Idx == 1 ? CS.CalleeGuids
747 CS.Frames[Idx - 2].Function))});
749 ProfileHasColumns |= StackFrame.Column;
751 if (StackFrame.Function == FuncGUID)
754 assert(Idx <= CS.Frames.size() && CS.Frames[Idx - 1].Function == FuncGUID);
766 auto *CalledFunction = CI->getCalledFunction();
767 if (CalledFunction && CalledFunction->isIntrinsic())
778 bool LeafFound =
false;
784 auto AllocInfoIter = LocHashToAllocInfo.
end();
785 auto CallSitesIter = LocHashToCallSites.end();
786 for (
const DILocation *DIL =
I.getDebugLoc(); DIL !=
nullptr;
787 DIL = DIL->getInlinedAt()) {
790 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
792 Name = DIL->getScope()->getSubprogram()->getName();
795 ProfileHasColumns ? DIL->getColumn() : 0);
801 AllocInfoIter = LocHashToAllocInfo.find(StackId);
802 CallSitesIter = LocHashToCallSites.find(StackId);
803 if (AllocInfoIter != LocHashToAllocInfo.end() ||
804 CallSitesIter != LocHashToCallSites.end())
818 if (AllocInfoIter != LocHashToAllocInfo.end() &&
822 AllocInfoIter->second, FullStackIdToAllocMatchInfo);
823 else if (CallSitesIter != LocHashToCallSites.end())
828 CallSitesIter->second, M, MatchedCallSites, ORE);
835 : MemoryProfileFileName(MemoryProfileFile), FS(FS) {
841 const InstrumentationOptions &Opts =
842 M.getContext().getLibraryOptions().get<InstrumentationOptions>();
845 if (M.empty() && M.globals().empty())
849 auto &Ctx = M.getContext();
851 if (
Error E = ReaderOrErr.takeError()) {
860 std::move(ReaderOrErr.get());
863 MemoryProfileFileName.data(),
StringRef(
"Cannot get MemProfReader")));
869 "Not a memory profile"));
874 Opts.memprof_annotate_static_data_prefix &&
875 annotateGlobalVariables(M,
MemProfReader->getDataAccessProfileData());
886 if (Opts.memprof_salvage_stale_profile)
893 std::map<uint64_t, AllocMatchInfo> FullStackIdToAllocMatchInfo;
897 std::set<std::vector<uint64_t>> MatchedCallSites;
902 uint64_t MaxColdSize = 0;
904 MaxColdSize = MemProfSum->getMaxColdTotalSize();
907 if (
F.isDeclaration())
913 FullStackIdToAllocMatchInfo, MatchedCallSites, UndriftMaps, ORE,
914 MaxColdSize, SeenStacks, SeenFrames);
917 if (Opts.memprof_print_match_info) {
918 for (
const auto &[Id, Info] : FullStackIdToAllocMatchInfo) {
919 for (
auto Frames : Info.MatchedFramesSet) {
924 <<
" context with id " << Id <<
" has total profiled size "
925 << Info.TotalSize <<
" is matched with " << Frames <<
" frames";
926 if (Opts.memprof_print_matched_alloc_stack) {
927 errs() <<
" and call stack";
928 for (
auto &
F : Info.CallStack)
935 for (
const auto &
CallStack : MatchedCallSites) {
936 errs() <<
"MemProf callsite match for inline call stack";
938 errs() <<
" " << StackId;
946bool MemProfUsePass::annotateGlobalVariables(
948 if (M.globals().empty())
951 if (!DataAccessProf) {
966 assert(!GVar.getSectionPrefix().has_value() &&
967 "GVar shouldn't have section prefix yet");
974 StringRef
Name = GVar.getName();
979 if (
Name.starts_with(
".str"))
982 if (
Name.starts_with(
".str")) {
985 LLVM_DEBUG(
dbgs() <<
"Cannot compute content hash for string literal "
994 std::optional<DataAccessProfRecord>
Record =
1002 if (Record &&
Record->AccessCount > 0) {
1003 ++NumOfMemProfHotGlobalVars;
1004 Changed |= GVar.setSectionPrefix(
"hot");
1006 <<
" is annotated as hot\n");
1008 ++NumOfMemProfColdGlobalVars;
1009 Changed |= GVar.setSectionPrefix(
"unlikely");
1012 <<
" is annotated as unlikely\n");
1014 ++NumOfMemProfUnknownGlobalVars;
1015 LLVM_DEBUG(
dbgs() <<
"Global variable " << Name <<
" is not annotated\n");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
static std::optional< uint64_t > getStringContentHash(const GlobalVariable &GVar)
static void addVPMetadata(const InstrumentationOptions &Opts, Module &M, Instruction &I, ArrayRef< GlobalValue::GUID > CalleeGuids)
static void addCallsiteMetadata(Instruction &I, ArrayRef< uint64_t > InlinedCallStack, LLVMContext &Ctx)
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 uint32_t getLineOffset(const DILocation *DIL)
static void readMemprof(const InstrumentationOptions &Opts, 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, DenseSet< uint64_t > &SeenStacks, DenseSet< uint64_t > &SeenFrames)
static bool isAllocationWithHotColdVariant(const InstrumentationOptions &Opts, const Function *Callee, const TargetLibraryInfo &TLI)
static void dumpInlineCallStack(Instruction &I, CallBase *CI, OptimizationRemarkEmitter &ORE, DenseSet< uint64_t > &SeenFrames, DenseSet< uint64_t > &SeenStacks, bool ProfileHasColumns)
static AllocationType addCallStack(CallStackTrie &AllocTrie, const AllocationInfo *AllocInfo, uint64_t FullStackId)
static void handleAllocSite(const InstrumentationOptions &Opts, 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 bool stackFrameIncludesInlinedCallStack(ArrayRef< Frame > ProfileCallStack, ArrayRef< uint64_t > InlinedCallStack)
static void handleCallSite(const InstrumentationOptions &Opts, 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)
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.
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
Get the array size.
bool empty() const
Check if the array is empty.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
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.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
LibFunc getLibFunc(StringRef funcName) 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.
std::pair< iterator, bool > insert(const ValueT &V)
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.
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI DenseMap< uint64_t, LocToLocMap > computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
DenseMap< LineLocation, LineLocation > LocToLocMap
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.
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;})
LLVM_ABI 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.
auto unique(Range &&R, Predicate P)
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
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.
cl::opt< bool > AnnotateStringLiteralSectionPrefix("memprof-annotate-string-literal-section-prefix", cl::init(true), cl::Hidden, cl::desc("If true, annotate the string literal data section prefix"))
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.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
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.
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