LLVM: lib/Transforms/IPO/MemProfContextDisambiguation.cpp File Reference (original) (raw)

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"
Enumerations
enum DotScope { All, Alloc, Context }
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 (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 (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 (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")
cl::opt< bool > llvm::EnableMemProfContextDisambiguation ("enable-memprof-context-disambiguation", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Enable MemProf context disambiguation"))
cl::opt< bool > llvm::SupportsHotColdNew ("supports-hot-cold-new", cl::init(false), cl::Hidden, cl::desc("Linking with hot/cold operator new interfaces"))
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 bool isMemProfClone (const Function &F)
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 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 ValueInfo findValueInfoForFunc (const Function &F, const Module &M, const ModuleSummaryIndex *ImportSummary, const Function *CallingFunc=nullptr)
static void checkAllocContextIds (const AllocInfo &AllocNode, const MDNode *MemProfMD, const CallStack< MDNode, MDNode::op_iterator > &CallsiteContext, const ModuleSummaryIndex *ImportSummary)
Variables
static cl::opt< std::string > DotFilePathPrefix ("memprof-dot-file-path-prefix", cl::init(""), cl::Hidden, cl::value_desc("filename"), cl::desc("Specify the path prefix of the MemProf dot files."))
static cl::opt< bool > ExportToDot ("memprof-export-to-dot", cl::init(false), cl::Hidden, cl::desc("Export graph to dot files."))
static cl::opt< bool > DoMergeIteration ("memprof-merge-iteration", cl::init(true), cl::Hidden, cl::desc("Iteratively apply merging on a node to catch new callers"))
static cl::opt< DotScope > DotGraphScope ("memprof-dot-scope", cl::desc("Scope of graph to export to dot"), cl::Hidden, cl::init(DotScope::All), cl::values(clEnumValN(DotScope::All, "all", "Export full callsite graph"), clEnumValN(DotScope::Alloc, "alloc", "Export only nodes with contexts feeding given " "-memprof-dot-alloc-id"), clEnumValN(DotScope::Context, "context", "Export only nodes with given -memprof-dot-context-id")))
static cl::opt< unsigned > AllocIdForDot ("memprof-dot-alloc-id", cl::init(0), cl::Hidden, cl::desc("Id of alloc to export if -memprof-dot-scope=alloc " "or to highlight if -memprof-dot-scope=all"))
static cl::opt< unsigned > ContextIdForDot ("memprof-dot-context-id", cl::init(0), cl::Hidden, cl::desc("Id of context to export if -memprof-dot-scope=context or to " "highlight otherwise"))
static cl::opt< bool > DumpCCG ("memprof-dump-ccg", cl::init(false), cl::Hidden, cl::desc("Dump CallingContextGraph to stdout after each stage."))
static cl::opt< bool > VerifyCCG ("memprof-verify-ccg", cl::init(false), cl::Hidden, cl::desc("Perform verification checks on CallingContextGraph."))
static cl::opt< bool > VerifyNodes ("memprof-verify-nodes", cl::init(false), cl::Hidden, cl::desc("Perform frequent verification checks on nodes."))
static cl::opt< std::string > MemProfImportSummary ("memprof-import-summary", cl::desc("Import summary to use for testing the ThinLTO backend via opt"), cl::Hidden)
static cl::opt< unsigned > TailCallSearchDepth ("memprof-tail-call-search-depth", cl::init(5), cl::Hidden, cl::desc("Max depth to recursively search for missing " "frames through tail calls."))
static cl::opt< bool > AllowRecursiveCallsites ("memprof-allow-recursive-callsites", cl::init(true), cl::Hidden, cl::desc("Allow cloning of callsites involved in recursive cycles"))
static cl::opt< bool > CloneRecursiveContexts ("memprof-clone-recursive-contexts", cl::init(true), cl::Hidden, cl::desc("Allow cloning of contexts through recursive cycles"))
static cl::opt< bool > MergeClones ("memprof-merge-clones", cl::init(true), cl::Hidden, cl::desc("Merge clones before assigning functions"))
static cl::opt< bool > AllowRecursiveContexts ("memprof-allow-recursive-contexts", cl::init(true), cl::Hidden, cl::desc("Allow cloning of contexts having recursive cycles"))
static cl::opt< unsigned > MemProfICPNoInlineThreshold ("memprof-icp-noinline-threshold", cl::init(2), cl::Hidden, cl::desc("Minimum absolute count for promoted target to be inlinable"))
static cl::opt< bool > llvm::MemProfRequireDefinitionForPromotion ("memprof-require-definition-for-promotion", cl::init(false), cl::Hidden, cl::desc("Require target function definition when promoting indirect calls"))
cl::opt< unsigned > llvm::MemProfTopNImportant ("memprof-top-n-important", cl::init(10), cl::Hidden, cl::desc("Number of largest cold contexts to consider important"))
cl::opt< bool > llvm::MemProfFixupImportant ("memprof-fixup-important", cl::init(true), cl::Hidden, cl::desc("Enables edge fixup for important contexts"))
static const std::string MemProfCloneSuffix = ".memprof."
template<typename DerivedCCG, typename FuncTy, typename CallTy>
bool DOTGraphTraits< constCallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::DoHighlight

DEBUG_TYPE

#define DEBUG_TYPE "memprof-context-disambiguation"

DotScope

checkAllocContextIds()

checkColdOrNotCold()

checkEdge()

template<typename DerivedCCG, typename FuncTy, typename CallTy>

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

checkNode()

template<typename DerivedCCG, typename FuncTy, typename CallTy>

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

ComputeHash()

createFunctionClones()

Definition at line 5457 of file MemProfContextDisambiguation.cpp.

References A(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::CloneFunction(), ComputeHash(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::contains(), llvm::GlobalAlias::create(), DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::GlobalValue::eraseFromParent(), F, llvm::Function::getFunction(), getMemProfFuncName(), I, llvm::GlobalValue::isDeclaration(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), and updateSubprogramLinkageName().

findValueInfoForFunc()

getAllocTypeString()

getMemProfCloneNum()

getMemProfFuncName()

isMemProfClone()

STATISTIC() [1/30]

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

STATISTIC() [2/30]

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

STATISTIC() [3/30]

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

STATISTIC() [4/30]

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

STATISTIC() [5/30]

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

STATISTIC() [6/30]

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

STATISTIC() [7/30]

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

STATISTIC() [8/30]

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

STATISTIC() [9/30]

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

STATISTIC() [10/30]

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

STATISTIC() [11/30]

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

STATISTIC() [12/30]

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

STATISTIC() [13/30]

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

STATISTIC() [14/30]

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

STATISTIC() [15/30]

STATISTIC() [16/30]

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

STATISTIC() [17/30]

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

STATISTIC() [18/30]

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

STATISTIC() [19/30]

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

STATISTIC() [20/30]

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

STATISTIC() [21/30]

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

STATISTIC() [22/30]

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

STATISTIC() [23/30]

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

STATISTIC() [24/30]

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

STATISTIC() [25/30]

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

STATISTIC() [26/30]

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

STATISTIC() [27/30]

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

STATISTIC() [28/30]

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

STATISTIC() [29/30]

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

STATISTIC() [30/30]

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

updateSubprogramLinkageName()

AllocIdForDot

cl::opt< unsigned > AllocIdForDot("memprof-dot-alloc-id", cl::init(0), cl::Hidden, cl::desc("Id of alloc to export if -memprof-dot-scope=alloc " "or to highlight if -memprof-dot-scope=all")) ( "memprof-dot-alloc-id" , cl::init(0) , cl::Hidden , cl::desc("Id of alloc to export if -memprof-dot-scope=alloc " "or to highlight if -memprof-dot-scope=all") ) static

AllowRecursiveCallsites

cl::opt< bool > AllowRecursiveCallsites("memprof-allow-recursive-callsites", cl::init(true), cl::Hidden, cl::desc("Allow cloning of callsites involved in recursive cycles")) ( "memprof-allow-recursive-callsites" , cl::init(true) , cl::Hidden , cl::desc("Allow cloning of callsites involved in recursive cycles") ) static

AllowRecursiveContexts

cl::opt< bool > AllowRecursiveContexts("memprof-allow-recursive-contexts", cl::init(true), cl::Hidden, cl::desc("Allow cloning of contexts having recursive cycles")) ( "memprof-allow-recursive-contexts" , cl::init(true) , cl::Hidden , cl::desc("Allow cloning of contexts having recursive cycles") ) static

CloneRecursiveContexts

cl::opt< bool > CloneRecursiveContexts("memprof-clone-recursive-contexts", cl::init(true), cl::Hidden, cl::desc("Allow cloning of contexts through recursive cycles")) ( "memprof-clone-recursive-contexts" , cl::init(true) , cl::Hidden , cl::desc("Allow cloning of contexts through recursive cycles") ) static

ContextIdForDot

cl::opt< unsigned > ContextIdForDot("memprof-dot-context-id", cl::init(0), cl::Hidden, cl::desc("Id of context to export if -memprof-dot-scope=context or to " "highlight otherwise")) ( "memprof-dot-context-id" , cl::init(0) , cl::Hidden , cl::desc("Id of context to export if -memprof-dot-scope=context or to " "highlight otherwise") ) static

Referenced by DOTGraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::DOTGraphTraits(), DOTGraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::getEdgeAttributes(), DOTGraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::getNodeAttributes(), DOTGraphTraits< const CallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::isNodeHidden(), and llvm::MemProfContextDisambiguation::MemProfContextDisambiguation().

DoMergeIteration

cl::opt< bool > DoMergeIteration("memprof-merge-iteration", cl::init(true), cl::Hidden, cl::desc("Iteratively apply merging on a node to catch new callers")) ( "memprof-merge-iteration" , cl::init(true) , cl::Hidden , cl::desc("Iteratively apply merging on a node to catch new callers") ) static

DotFilePathPrefix

cl::opt< std::string > DotFilePathPrefix("memprof-dot-file-path-prefix", cl::init(""), cl::Hidden, cl::value_desc("filename"), cl::desc("Specify the path prefix of the MemProf dot files.")) ( "memprof-dot-file-path-prefix" , cl::init("") , cl::Hidden , cl::value_desc("filename") , cl::desc("Specify the path prefix of the MemProf dot files.") ) static

DotGraphScope

cl::opt< DotScope > DotGraphScope("memprof-dot-scope", cl::desc("Scope of graph to export to dot"), cl::Hidden, cl::init(DotScope::All), cl::values( clEnumValN(DotScope::All, "all", "Export full callsite graph"), clEnumValN(DotScope::Alloc, "alloc", "Export only nodes with contexts feeding given " "-memprof-dot-alloc-id"), clEnumValN(DotScope::Context, "context", "Export only nodes with given -memprof-dot-context-id"))) ( "memprof-dot-scope" , cl::desc("Scope of graph to export to dot") , cl::Hidden , cl::init(DotScope::All) , cl::values( clEnumValN(DotScope::All, "all", "Export full callsite graph"), clEnumValN(DotScope::Alloc, "alloc", "Export only nodes with contexts feeding given " "-memprof-dot-alloc-id"), clEnumValN(DotScope::Context, "context", "Export only nodes with given -memprof-dot-context-id")) ) static

DOTGraphTraits< constCallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::DoHighlight

template<typename DerivedCCG, typename FuncTy, typename CallTy>

bool DOTGraphTraits< constCallsiteContextGraph< DerivedCCG, FuncTy, CallTy > * >::DoHighlight

DumpCCG

cl::opt< bool > DumpCCG("memprof-dump-ccg", cl::init(false), cl::Hidden, cl::desc("Dump CallingContextGraph to stdout after each stage.")) ( "memprof-dump-ccg" , cl::init(false) , cl::Hidden , cl::desc("Dump CallingContextGraph to stdout after each stage.") ) static

ExportToDot

cl::opt< bool > ExportToDot("memprof-export-to-dot", cl::init(false), cl::Hidden, cl::desc("Export graph to dot files.")) ( "memprof-export-to-dot" , cl::init(false) , cl::Hidden , cl::desc("Export graph to dot files.") ) static

MemProfCloneSuffix

MemProfICPNoInlineThreshold

cl::opt< unsigned > MemProfICPNoInlineThreshold("memprof-icp-noinline-threshold", cl::init(2), cl::Hidden, cl::desc("Minimum absolute count for promoted target to be inlinable")) ( "memprof-icp-noinline-threshold" , cl::init(2) , cl::Hidden , cl::desc("Minimum absolute count for promoted target to be inlinable") ) static

MemProfImportSummary

cl::opt< std::string > MemProfImportSummary("memprof-import-summary", cl::desc("Import summary to use for testing the ThinLTO backend via opt"), cl::Hidden) ( "memprof-import-summary" , cl::desc("Import summary to use for testing the ThinLTO backend via opt") , cl::Hidden ) static

MergeClones

cl::opt< bool > MergeClones("memprof-merge-clones", cl::init(true), cl::Hidden, cl::desc("Merge clones before assigning functions")) ( "memprof-merge-clones" , cl::init(true) , cl::Hidden , cl::desc("Merge clones before assigning functions") ) static

TailCallSearchDepth

cl::opt< unsigned > TailCallSearchDepth("memprof-tail-call-search-depth", cl::init(5), cl::Hidden, cl::desc("Max depth to recursively search for missing " "frames through tail calls.")) ( "memprof-tail-call-search-depth" , cl::init(5) , cl::Hidden , cl::desc("Max depth to recursively search for missing " "frames through tail calls.") ) static

VerifyCCG

cl::opt< bool > VerifyCCG("memprof-verify-ccg", cl::init(false), cl::Hidden, cl::desc("Perform verification checks on CallingContextGraph.")) ( "memprof-verify-ccg" , cl::init(false) , cl::Hidden , cl::desc("Perform verification checks on CallingContextGraph.") ) static

VerifyNodes

cl::opt< bool > VerifyNodes("memprof-verify-nodes", cl::init(false), cl::Hidden, cl::desc("Perform frequent verification checks on nodes.")) ( "memprof-verify-nodes" , cl::init(false) , cl::Hidden , cl::desc("Perform frequent verification checks on nodes.") ) static