LLVM 24.0.0git
MemProfContextDisambiguation.cpp File Reference

Go to the source code of this file.

Classes

struct  llvm::simplify_type< IndexCall >
struct  llvm::simplify_type< const IndexCall >
struct  llvm::DenseMapInfo< CallsiteContextGraph< ModuleCallsiteContextGraph, Function, Instruction * >::CallInfo >
struct  llvm::DenseMapInfo< CallsiteContextGraph< IndexCallsiteContextGraph, FunctionSummary, IndexCall >::CallInfo >
struct  llvm::DenseMapInfo< IndexCall >
struct  GraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >
struct  DOTGraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >

Namespaces

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

Macros

#define DEBUG_TYPE   "memprof-context-disambiguation"

Functions

 STATISTIC (FunctionClonesAnalysis, "Number of function clones created during whole program analysis")
 STATISTIC (FunctionClonesThinBackend, "Number of function clones created during ThinLTO backend")
 STATISTIC (FunctionsClonedThinBackend, "Number of functions that had clones created during ThinLTO backend")
 STATISTIC (FunctionCloneDuplicatesThinBackend, "Number of function clone duplicates detected during ThinLTO backend")
 STATISTIC (AllocTypeNotCold, "Number of not cold static allocations (possibly " "cloned) during whole program analysis")
 STATISTIC (AllocTypeCold, "Number of cold static allocations (possibly cloned) " "during whole program analysis")
 STATISTIC (AllocTypeAmbiguous, "Number of ambiguous static allocations (possibly cloned) during " "whole program analysis")
 STATISTIC (AllocTypeNotColdThinBackend, "Number of not cold static allocations (possibly cloned) during " "ThinLTO backend")
 STATISTIC (AllocTypeColdThinBackend, "Number of cold static allocations " "(possibly cloned) during ThinLTO backend")
 STATISTIC (AllocTypeAmbiguousThinBackend, "Number of ambiguous static allocations (possibly cloned) during " "ThinLTO backend")
 STATISTIC (OrigAllocsThinBackend, "Number of original (not cloned) allocations with memprof profiles " "during ThinLTO backend")
 STATISTIC (AllocVersionsThinBackend, "Number of allocation versions (including clones) during ThinLTO backend")
 STATISTIC (MaxAllocVersionsThinBackend, "Maximum number of allocation versions created for an original " "allocation during ThinLTO backend")
 STATISTIC (UnclonableAllocsThinBackend, "Number of unclonable ambigous allocations during ThinLTO backend")
 STATISTIC (RemovedEdgesWithMismatchedCallees, "Number of edges removed due to mismatched callees (profiled vs IR)")
 STATISTIC (FoundProfiledCalleeCount, "Number of profiled callees found via tail calls")
 STATISTIC (FoundProfiledCalleeDepth, "Aggregate depth of profiled callees found via tail calls")
 STATISTIC (FoundProfiledCalleeMaxDepth, "Maximum depth of profiled callees found via tail calls")
 STATISTIC (FoundProfiledCalleeNonUniquelyCount, "Number of profiled callees found via multiple tail call chains")
 STATISTIC (FoundProfiledCalleeIndirectTailCallCount, "Number of tail calls in chains to profiled callees that are " "indirect (thin link)")
 STATISTIC (IndirectTailCallsRecordedForICPThinBackend, "Number of indirect tail calls recorded for ICP for cloning during " "ThinLTO backend")
 STATISTIC (DeferredBackedges, "Number of backedges with deferred cloning")
 STATISTIC (NewMergedNodes, "Number of new nodes created during merging")
 STATISTIC (NonNewMergedNodes, "Number of non new nodes used during merging")
 STATISTIC (MissingAllocForContextId, "Number of missing alloc nodes for context ids")
 STATISTIC (SkippedCallsCloning, "Number of calls skipped during cloning due to unexpected operand")
 STATISTIC (MismatchedCloneAssignments, "Number of callsites assigned to call multiple non-matching clones")
 STATISTIC (TotalMergeInvokes, "Number of merge invocations for nodes")
 STATISTIC (TotalMergeIters, "Number of merge iterations for nodes")
 STATISTIC (MaxMergeIters, "Max merge iterations for nodes")
 STATISTIC (NumImportantContextIds, "Number of important context ids")
 STATISTIC (NumFixupEdgeIdsInserted, "Number of fixup edge ids inserted")
 STATISTIC (NumFixupEdgesAdded, "Number of fixup edges added")
 STATISTIC (NumFixedContexts, "Number of contexts with fixed edges")
 STATISTIC (NumImplicitCallersAssigned, "Number of callsite clones without an edge to a callee's clones " "assigned the callee function clone of their original node")
 STATISTIC (NumImplicitCallersSourced, "Number of calls in function clones whose callee was taken from a " "callsite clone an implicit caller requires")
 STATISTIC (NumTrimmedContextIds, "Number of context ids with call stacks trimmed at a callsite")
 STATISTIC (NumImplicitCallersUnresolved, "Number of callsite clones without an edge to a callee's clones " "left in a function clone calling a conflicting callee clone")
 STATISTIC (AliaseesPrevailingInDiffModuleFromAlias, "Number of aliasees prevailing in a different module than its alias")
 STATISTIC (NumClonedCalleeCallsites, "Number of summary callsites assigned to call a cloned callee (thin " "link)")
 STATISTIC (NumClonedCalleeIndirectCallsites, "Number of summary callsites assigned to call a cloned callee with " "an indirect call edge (thin link)")
 STATISTIC (NumClonedCalleeEdgesMarkedRequiresDeclImport, "Number of summary indirect call edges to cloned callees marked as " "requiring a declaration import (thin link)")
 STATISTIC (NumCallsAssignedTrimmedInlinedContexts, "Number of calls assigned contexts trimmed within their inlined " "stack id sequence")
 STATISTIC (NumTrimmedInlinedContextIds, "Number of (duplicated) context ids for contexts trimmed within a " "call's inlined stack id sequence")
static std::string getAllocTypeString (uint8_t AllocTypes)
template<typename DerivedCCG, typename FuncTy, typename CallTy>
static void checkEdge (const std::shared_ptr< ContextEdge< DerivedCCG, FuncTy, CallTy > > &Edge)
template<typename DerivedCCG, typename FuncTy, typename CallTy>
static void checkNode (const ContextNode< DerivedCCG, FuncTy, CallTy > *Node, bool CheckEdges=true)
static std::string getMemProfFuncName (Twine Base, unsigned CloneNo)
static unsigned getMemProfCloneNum (const Function &F)
bool checkColdOrNotCold (uint8_t AllocType)
static void updateSubprogramLinkageName (Function *NewFunc, StringRef Name)
uint64_t ComputeHash (const FunctionSummary *FS, unsigned I)
static bool clonesHaveSameVersions (const FunctionSummary *FS, unsigned I, unsigned J)
static SmallVector< std::unique_ptr< ValueToValueMapTy >, 4 > createFunctionClones (Function &F, unsigned NumClones, Module &M, OptimizationRemarkEmitter &ORE, std::map< const Function *, SmallPtrSet< const GlobalAlias *, 1 > > &FuncToAliasMap, FunctionSummary *FS)
static std::optional< GlobalValue::GUID > getImportedAliasGUID (const Function &F)
static ValueInfo findValueInfoForGV (const GlobalValue &GV, const Module &M, const ModuleSummaryIndex *ImportSummary, const Function *CallingFunc=nullptr)
static const CallsiteInfo * findIndirectTailCallCallsite (uint64_t CandidateGUID, const DenseMap< ValueInfo, CallsiteInfo > &MapTailCallCalleeVIToCallsite, std::optional< DenseMap< uint64_t, const CallsiteInfo * > > &OrigNameGUIDToTailCallCallsite, std::optional< DenseMap< ValueInfo, const GlobalAlias * > > &AliasVIToGV, const Module &M, const ModuleSummaryIndex *ImportSummary, InstrProfSymtab &Symtab)
static void checkAllocContextIds (const AllocInfo &AllocNode, const MDNode *MemProfMD, const CallStack< MDNode, MDNode::op_iterator > &CallsiteContext, const ModuleSummaryIndex *ImportSummary)
static std::unique_ptr< ModuleSummaryIndex > loadImportSummaryForTesting (StringRef Filename)
static void checkDotOptions (const IPOOptions &Opts)
static void updateClonedCalleeEdgesForImport (ModuleSummaryIndex &Index, llvm::function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)

Variables

cl::opt< bool > llvm::MemProfUseAmbiguousAttributes

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "memprof-context-disambiguation"

Definition at line 56 of file MemProfContextDisambiguation.cpp.

Function Documentation

◆ checkAllocContextIds()

◆ checkColdOrNotCold()

bool checkColdOrNotCold ( uint8_t AllocType)

Definition at line 4694 of file MemProfContextDisambiguation.cpp.

References llvm::Cold, and llvm::NotCold.

◆ checkDotOptions()

void checkDotOptions ( const IPOOptions & Opts)
static

◆ checkEdge()

template<typename DerivedCCG, typename FuncTy, typename CallTy>
void checkEdge ( const std::shared_ptr< ContextEdge< DerivedCCG, FuncTy, CallTy > > & Edge)
static

Definition at line 1755 of file MemProfContextDisambiguation.cpp.

References assert(), and llvm::None.

Referenced by checkNode().

◆ checkNode()

template<typename DerivedCCG, typename FuncTy, typename CallTy>
void checkNode ( const ContextNode< DerivedCCG, FuncTy, CallTy > * Node,
bool CheckEdges = true )
static

◆ clonesHaveSameVersions()

bool clonesHaveSameVersions ( const FunctionSummary * FS,
unsigned I,
unsigned J )
static

Definition at line 6722 of file MemProfContextDisambiguation.cpp.

References assert(), and I.

Referenced by createFunctionClones().

◆ ComputeHash()

◆ createFunctionClones()

◆ findIndirectTailCallCallsite()

◆ findValueInfoForGV()

◆ getAllocTypeString()

std::string getAllocTypeString ( uint8_t AllocTypes)
static

Definition at line 1555 of file MemProfContextDisambiguation.cpp.

References llvm::Cold, and llvm::NotCold.

◆ getImportedAliasGUID()

std::optional< GlobalValue::GUID > getImportedAliasGUID ( const Function & F)
static

Definition at line 6861 of file MemProfContextDisambiguation.cpp.

References llvm::mdconst::extract(), and F.

Referenced by findValueInfoForGV().

◆ getMemProfCloneNum()

unsigned getMemProfCloneNum ( const Function & F)
static

Definition at line 2656 of file MemProfContextDisambiguation.cpp.

References assert(), F, and llvm::isMemProfClone().

◆ getMemProfFuncName()

std::string getMemProfFuncName ( Twine Base,
unsigned CloneNo )
static

◆ loadImportSummaryForTesting()

◆ STATISTIC() [1/44]

STATISTIC ( AliaseesPrevailingInDiffModuleFromAlias ,
"Number of aliasees prevailing in a different module than its alias"  )

◆ STATISTIC() [2/44]

STATISTIC ( AllocTypeAmbiguous ,
"Number of ambiguous static allocations (possibly cloned) during " "whole program analysis"  )

◆ STATISTIC() [3/44]

STATISTIC ( AllocTypeAmbiguousThinBackend ,
"Number of ambiguous static allocations (possibly cloned) during " "ThinLTO backend"  )

◆ STATISTIC() [4/44]

STATISTIC ( AllocTypeCold ,
"Number of cold static allocations (possibly cloned) " "during whole program analysis"  )

◆ STATISTIC() [5/44]

STATISTIC ( AllocTypeColdThinBackend ,
"Number of cold static allocations " "(possibly cloned) during ThinLTO backend"  )

◆ STATISTIC() [6/44]

STATISTIC ( AllocTypeNotCold ,
"Number of not cold static allocations (possibly " "cloned) during whole program analysis"  )

◆ STATISTIC() [7/44]

STATISTIC ( AllocTypeNotColdThinBackend ,
"Number of not cold static allocations (possibly cloned) during " "ThinLTO backend"  )

◆ STATISTIC() [8/44]

STATISTIC ( AllocVersionsThinBackend ,
"Number of allocation versions (including clones) during ThinLTO backend"  )

◆ STATISTIC() [9/44]

STATISTIC ( DeferredBackedges ,
"Number of backedges with deferred cloning"  )

◆ STATISTIC() [10/44]

STATISTIC ( FoundProfiledCalleeCount ,
"Number of profiled callees found via tail calls"  )

◆ STATISTIC() [11/44]

STATISTIC ( FoundProfiledCalleeDepth ,
"Aggregate depth of profiled callees found via tail calls"  )

◆ STATISTIC() [12/44]

STATISTIC ( FoundProfiledCalleeIndirectTailCallCount ,
"Number of tail calls in chains to profiled callees that are " "indirect (thin link)"  )

◆ STATISTIC() [13/44]

STATISTIC ( FoundProfiledCalleeMaxDepth ,
"Maximum depth of profiled callees found via tail calls"  )

◆ STATISTIC() [14/44]

STATISTIC ( FoundProfiledCalleeNonUniquelyCount ,
"Number of profiled callees found via multiple tail call chains"  )

◆ STATISTIC() [15/44]

STATISTIC ( FunctionCloneDuplicatesThinBackend ,
"Number of function clone duplicates detected during ThinLTO backend"  )

◆ STATISTIC() [16/44]

STATISTIC ( FunctionClonesAnalysis ,
"Number of function clones created during whole program analysis"  )

◆ STATISTIC() [17/44]

STATISTIC ( FunctionClonesThinBackend ,
"Number of function clones created during ThinLTO backend"  )

◆ STATISTIC() [18/44]

STATISTIC ( FunctionsClonedThinBackend ,
"Number of functions that had clones created during ThinLTO backend"  )

◆ STATISTIC() [19/44]

STATISTIC ( IndirectTailCallsRecordedForICPThinBackend ,
"Number of indirect tail calls recorded for ICP for cloning during " "ThinLTO backend"  )

◆ STATISTIC() [20/44]

STATISTIC ( MaxAllocVersionsThinBackend ,
"Maximum number of allocation versions created for an original " "allocation during ThinLTO backend"  )

◆ STATISTIC() [21/44]

STATISTIC ( MaxMergeIters ,
"Max merge iterations for nodes"  )

◆ STATISTIC() [22/44]

STATISTIC ( MismatchedCloneAssignments ,
"Number of callsites assigned to call multiple non-matching clones"  )

◆ STATISTIC() [23/44]

STATISTIC ( MissingAllocForContextId ,
"Number of missing alloc nodes for context ids"  )

◆ STATISTIC() [24/44]

STATISTIC ( NewMergedNodes ,
"Number of new nodes created during merging"  )

◆ STATISTIC() [25/44]

STATISTIC ( NonNewMergedNodes ,
"Number of non new nodes used during merging"  )

◆ STATISTIC() [26/44]

STATISTIC ( NumCallsAssignedTrimmedInlinedContexts ,
"Number of calls assigned contexts trimmed within their inlined " "stack id sequence"  )

◆ STATISTIC() [27/44]

STATISTIC ( NumClonedCalleeCallsites ,
"Number of summary callsites assigned to call a cloned callee (thin " "link)"  )

◆ STATISTIC() [28/44]

STATISTIC ( NumClonedCalleeEdgesMarkedRequiresDeclImport ,
"Number of summary indirect call edges to cloned callees marked as " "requiring a declaration import (thin link)"  )

◆ STATISTIC() [29/44]

STATISTIC ( NumClonedCalleeIndirectCallsites ,
"Number of summary callsites assigned to call a cloned callee with " "an indirect call edge (thin link)"  )

◆ STATISTIC() [30/44]

STATISTIC ( NumFixedContexts ,
"Number of contexts with fixed edges"  )

◆ STATISTIC() [31/44]

STATISTIC ( NumFixupEdgeIdsInserted ,
"Number of fixup edge ids inserted"  )

◆ STATISTIC() [32/44]

STATISTIC ( NumFixupEdgesAdded ,
"Number of fixup edges added"  )

◆ STATISTIC() [33/44]

STATISTIC ( NumImplicitCallersAssigned ,
"Number of callsite clones without an edge to a callee's clones " "assigned the callee function clone of their original node"  )

◆ STATISTIC() [34/44]

STATISTIC ( NumImplicitCallersSourced ,
"Number of calls in function clones whose callee was taken from a " "callsite clone an implicit caller requires"  )

◆ STATISTIC() [35/44]

STATISTIC ( NumImplicitCallersUnresolved ,
"Number of callsite clones without an edge to a callee's clones " "left in a function clone calling a conflicting callee clone"  )

◆ STATISTIC() [36/44]

STATISTIC ( NumImportantContextIds ,
"Number of important context ids"  )

◆ STATISTIC() [37/44]

STATISTIC ( NumTrimmedContextIds ,
"Number of context ids with call stacks trimmed at a callsite"  )

◆ STATISTIC() [38/44]

STATISTIC ( NumTrimmedInlinedContextIds ,
"Number of (duplicated) context ids for contexts trimmed within a " "call's inlined stack id sequence"  )

◆ STATISTIC() [39/44]

STATISTIC ( OrigAllocsThinBackend ,
"Number of original (not cloned) allocations with memprof profiles " "during ThinLTO backend"  )

◆ STATISTIC() [40/44]

STATISTIC ( RemovedEdgesWithMismatchedCallees ,
"Number of edges removed due to mismatched callees (profiled vs IR)"  )

◆ STATISTIC() [41/44]

STATISTIC ( SkippedCallsCloning ,
"Number of calls skipped during cloning due to unexpected operand"  )

◆ STATISTIC() [42/44]

STATISTIC ( TotalMergeInvokes ,
"Number of merge invocations for nodes"  )

◆ STATISTIC() [43/44]

STATISTIC ( TotalMergeIters ,
"Number of merge iterations for nodes"  )

◆ STATISTIC() [44/44]

STATISTIC ( UnclonableAllocsThinBackend ,
"Number of unclonable ambigous allocations during ThinLTO backend"  )

◆ updateClonedCalleeEdgesForImport()

◆ updateSubprogramLinkageName()