LLVM 22.0.0git
MemProfUse.cpp File Reference

Go to the source code of this file.

Classes

struct  AllocMatchInfo
struct  CallSiteEntry
struct  CallSiteEntryHash

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "memprof"

Functions

 STATISTIC (NumOfMemProfMissing, "Number of functions without memory profile.")
 STATISTIC (NumOfMemProfMismatch, "Number of functions having mismatched memory profile hash.")
 STATISTIC (NumOfMemProfFunc, "Number of functions having valid memory profile.")
 STATISTIC (NumOfMemProfAllocContextProfiles, "Number of alloc contexts in memory profile.")
 STATISTIC (NumOfMemProfCallSiteProfiles, "Number of callsites in memory profile.")
 STATISTIC (NumOfMemProfMatchedAllocContexts, "Number of matched memory profile alloc contexts.")
 STATISTIC (NumOfMemProfMatchedAllocs, "Number of matched memory profile allocs.")
 STATISTIC (NumOfMemProfMatchedCallSites, "Number of matched memory profile callsites.")
 STATISTIC (NumOfMemProfHotGlobalVars, "Number of global vars annotated with 'hot' section prefix.")
 STATISTIC (NumOfMemProfColdGlobalVars, "Number of global vars annotated with 'unlikely' section prefix.")
 STATISTIC (NumOfMemProfUnknownGlobalVars, "Number of global vars with unknown hotness (no section prefix).")
 STATISTIC (NumOfMemProfExplicitSectionGlobalVars, "Number of global vars with user-specified section (not annotated).")
static void addCallsiteMetadata (Instruction &I, ArrayRef< uint64_t > InlinedCallStack, LLVMContext &Ctx)
static uint64_t computeStackId (GlobalValue::GUID Function, uint32_t LineOffset, uint32_t Column)
static uint64_t computeStackId (const memprof::Frame &Frame)
static AllocationType addCallStack (CallStackTrie &AllocTrie, const AllocationInfo *AllocInfo, uint64_t FullStackId)
static bool stackFrameIncludesInlinedCallStack (ArrayRef< Frame > ProfileCallStack, ArrayRef< uint64_t > InlinedCallStack)
static bool isAllocationWithHotColdVariant (const Function *Callee, const TargetLibraryInfo &TLI)
static void undriftMemProfRecord (const DenseMap< uint64_t, LocToLocMap > &UndriftMaps, memprof::MemProfRecord &MemProfRec)
static void addVPMetadata (Module &M, Instruction &I, ArrayRef< GlobalValue::GUID > CalleeGuids)
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< std::pair< uint64_t, unsigned >, AllocMatchInfo > &FullStackIdToAllocMatchInfo)
static void handleCallSite (Instruction &I, const Function *CalledFunction, ArrayRef< uint64_t > InlinedCallStack, const std::unordered_set< CallSiteEntry, CallSiteEntryHash > &CallSiteEntries, Module &M, std::set< std::vector< uint64_t > > &MatchedCallSites)
static void readMemprof (Module &M, Function &F, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI, std::map< std::pair< uint64_t, unsigned >, AllocMatchInfo > &FullStackIdToAllocMatchInfo, std::set< std::vector< uint64_t > > &MatchedCallSites, DenseMap< uint64_t, LocToLocMap > &UndriftMaps, OptimizationRemarkEmitter &ORE, uint64_t MaxColdSize)
static bool hasExplicitSectionName (const GlobalVariable &GVar)

Variables

cl::opt< boolllvm::PGOWarnMissing
cl::opt< boolllvm::NoPGOWarnMismatchComdatWeak
static cl::opt< boolClMemProfMatchHotColdNew ("memprof-match-hot-cold-new", cl::desc("Match allocation profiles onto existing hot/cold operator new calls"), cl::Hidden, cl::init(false))
static cl::opt< boolClPrintMemProfMatchInfo ("memprof-print-match-info", cl::desc("Print matching stats for each allocation " "context in this module's profiles"), cl::Hidden, cl::init(false))
static cl::opt< boolSalvageStaleProfile ("memprof-salvage-stale-profile", cl::desc("Salvage stale MemProf profile"), cl::init(false), cl::Hidden)
static cl::opt< boolClMemProfAttachCalleeGuids ("memprof-attach-calleeguids", cl::desc("Attach calleeguids as value profile metadata for indirect calls."), cl::init(true), cl::Hidden)
static cl::opt< unsignedMinMatchedColdBytePercent ("memprof-matching-cold-threshold", cl::init(100), cl::Hidden, cl::desc("Min percent of cold bytes matched to hint allocation cold"))
static cl::opt< boolAnnotateStaticDataSectionPrefix ("memprof-annotate-static-data-prefix", cl::init(false), cl::Hidden, cl::desc("If true, annotate the static data section prefix"))

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "memprof"

Definition at line 41 of file MemProfUse.cpp.

Function Documentation

◆ addCallsiteMetadata()

void addCallsiteMetadata ( Instruction & I,
ArrayRef< uint64_t > InlinedCallStack,
LLVMContext & Ctx )
static

Definition at line 107 of file MemProfUse.cpp.

References llvm::memprof::buildCallstackMetadata(), and I.

Referenced by handleAllocSite(), and handleCallSite().

◆ addCallStack()

◆ addVPMetadata()

◆ computeStackId() [1/2]

◆ computeStackId() [2/2]

uint64_t computeStackId ( GlobalValue::GUID Function,
uint32_t LineOffset,
uint32_t Column )
static

◆ handleAllocSite()

◆ handleCallSite()

void handleCallSite ( Instruction & I,
const Function * CalledFunction,
ArrayRef< uint64_t > InlinedCallStack,
const std::unordered_set< CallSiteEntry, CallSiteEntryHash > & CallSiteEntries,
Module & M,
std::set< std::vector< uint64_t > > & MatchedCallSites )
static

◆ hasExplicitSectionName()

bool hasExplicitSectionName ( const GlobalVariable & GVar)
static

◆ isAllocationWithHotColdVariant()

bool isAllocationWithHotColdVariant ( const Function * Callee,
const TargetLibraryInfo & TLI )
static

◆ readMemprof()

◆ stackFrameIncludesInlinedCallStack()

bool stackFrameIncludesInlinedCallStack ( ArrayRef< Frame > ProfileCallStack,
ArrayRef< uint64_t > InlinedCallStack )
static

◆ STATISTIC() [1/12]

STATISTIC ( NumOfMemProfAllocContextProfiles ,
"Number of alloc contexts in memory profile."  )

◆ STATISTIC() [2/12]

STATISTIC ( NumOfMemProfCallSiteProfiles ,
"Number of callsites in memory profile."  )

◆ STATISTIC() [3/12]

STATISTIC ( NumOfMemProfColdGlobalVars ,
"Number of global vars annotated with 'unlikely' section prefix."  )

◆ STATISTIC() [4/12]

STATISTIC ( NumOfMemProfExplicitSectionGlobalVars ,
"Number of global vars with user-specified section (not annotated)."  )

◆ STATISTIC() [5/12]

STATISTIC ( NumOfMemProfFunc ,
"Number of functions having valid memory profile."  )

◆ STATISTIC() [6/12]

STATISTIC ( NumOfMemProfHotGlobalVars ,
"Number of global vars annotated with 'hot' section prefix."  )

◆ STATISTIC() [7/12]

STATISTIC ( NumOfMemProfMatchedAllocContexts ,
"Number of matched memory profile alloc contexts."  )

◆ STATISTIC() [8/12]

STATISTIC ( NumOfMemProfMatchedAllocs ,
"Number of matched memory profile allocs."  )

◆ STATISTIC() [9/12]

STATISTIC ( NumOfMemProfMatchedCallSites ,
"Number of matched memory profile callsites."  )

◆ STATISTIC() [10/12]

STATISTIC ( NumOfMemProfMismatch ,
"Number of functions having mismatched memory profile hash."  )

◆ STATISTIC() [11/12]

STATISTIC ( NumOfMemProfMissing ,
"Number of functions without memory profile."  )

◆ STATISTIC() [12/12]

STATISTIC ( NumOfMemProfUnknownGlobalVars ,
"Number of global vars with unknown hotness (no section prefix)."  )

◆ undriftMemProfRecord()

Variable Documentation

◆ AnnotateStaticDataSectionPrefix

cl::opt< bool > AnnotateStaticDataSectionPrefix("memprof-annotate-static-data-prefix", cl::init(false), cl::Hidden, cl::desc("If true, annotate the static data section prefix")) ( "memprof-annotate-static-data-prefix" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("If true, annotate the static data section prefix")  )
static

◆ ClMemProfAttachCalleeGuids

cl::opt< bool > ClMemProfAttachCalleeGuids("memprof-attach-calleeguids", cl::desc( "Attach calleeguids as value profile metadata for indirect calls."), cl::init(true), cl::Hidden) ( "memprof-attach-calleeguids" ,
cl::desc( "Attach calleeguids as value profile metadata for indirect calls.") ,
cl::init(true) ,
cl::Hidden  )
static

Referenced by addVPMetadata().

◆ ClMemProfMatchHotColdNew

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)) ( "memprof-match-hot-cold-new" ,
cl::desc( "Match allocation profiles onto existing hot/cold operator new calls") ,
cl::Hidden ,
cl::init(false)  )
static

◆ ClPrintMemProfMatchInfo

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)) ( "memprof-print-match-info" ,
cl::desc("Print matching stats for each allocation " "context in this module's profiles") ,
cl::Hidden ,
cl::init(false)  )
static

◆ MinMatchedColdBytePercent

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")) ( "memprof-matching-cold-threshold" ,
cl::init(100) ,
cl::Hidden ,
cl::desc("Min percent of cold bytes matched to hint allocation cold")  )
static

Referenced by handleAllocSite().

◆ SalvageStaleProfile

cl::opt< bool > SalvageStaleProfile("memprof-salvage-stale-profile", cl::desc("Salvage stale MemProf profile"), cl::init(false), cl::Hidden) ( "memprof-salvage-stale-profile" ,
cl::desc("Salvage stale MemProf profile") ,
cl::init(false) ,
cl::Hidden  )
static