LLVM 18.0.0git
Classes | Namespaces | Macros | Functions | Variables
MemProfContextDisambiguation.cpp File Reference
#include "llvm/Transforms/IPO/MemProfContextDisambiguation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/MemoryProfileInfo.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <sstream>
#include <vector>

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< typename CallsiteContextGraph< ModuleCallsiteContextGraph, Function, Instruction * >::CallInfo >
 
struct  llvm::DenseMapInfo< typename 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 (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")
 
cl::opt< boolllvm::SupportsHotColdNew ("supports-hot-cold-new", cl::init(false), cl::Hidden, cl::desc("Linking with hot/cold operator new interfaces"))
 
static std::string getMemProfFuncName (Twine Base, unsigned CloneNo)
 
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)
 
bool checkColdOrNotCold (uint8_t AllocType)
 
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)
 
static ValueInfo findValueInfoForFunc (const Function &F, const Module &M, 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< boolExportToDot ("memprof-export-to-dot", cl::init(false), cl::Hidden, cl::desc("Export graph to dot files."))
 
static cl::opt< boolDumpCCG ("memprof-dump-ccg", cl::init(false), cl::Hidden, cl::desc("Dump CallingContextGraph to stdout after each stage."))
 
static cl::opt< boolVerifyCCG ("memprof-verify-ccg", cl::init(false), cl::Hidden, cl::desc("Perform verification checks on CallingContextGraph."))
 
static cl::opt< boolVerifyNodes ("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 const std::string MemProfCloneSuffix = ".memprof."
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "memprof-context-disambiguation"

Definition at line 52 of file MemProfContextDisambiguation.cpp.

Function Documentation

◆ checkColdOrNotCold()

bool checkColdOrNotCold ( uint8_t  AllocType)

Definition at line 2058 of file MemProfContextDisambiguation.cpp.

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

◆ checkEdge()

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

Definition at line 1765 of file MemProfContextDisambiguation.cpp.

References assert().

◆ checkNode()

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

◆ createFunctionClones()

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 
)
static

◆ findValueInfoForFunc()

static ValueInfo findValueInfoForFunc ( const Function F,
const Module M,
const ModuleSummaryIndex ImportSummary 
)
static

◆ getAllocTypeString()

static std::string getAllocTypeString ( uint8_t  AllocTypes)
static

Definition at line 1676 of file MemProfContextDisambiguation.cpp.

◆ getMemProfFuncName()

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

Definition at line 1392 of file MemProfContextDisambiguation.cpp.

References llvm::sampleprof::Base, and MemProfCloneSuffix.

Referenced by createFunctionClones().

◆ STATISTIC() [1/11]

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

◆ STATISTIC() [2/11]

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

◆ STATISTIC() [3/11]

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

◆ STATISTIC() [4/11]

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

◆ STATISTIC() [5/11]

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

◆ STATISTIC() [6/11]

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

◆ STATISTIC() [7/11]

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

◆ STATISTIC() [8/11]

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

◆ STATISTIC() [9/11]

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

◆ STATISTIC() [10/11]

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

◆ STATISTIC() [11/11]

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

Variable Documentation

◆ 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

◆ 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

const std::string MemProfCloneSuffix = ".memprof."
static

Definition at line 1390 of file MemProfContextDisambiguation.cpp.

Referenced by getMemProfFuncName().

◆ 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

◆ 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