LLVM: lib/Transforms/Instrumentation/MemProfInstrumentation.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "memprof"
Functions
STATISTIC (NumInstrumentedReads, "Number of instrumented reads")
STATISTIC (NumInstrumentedWrites, "Number of instrumented writes")
STATISTIC (NumSkippedStackReads, "Number of non-instrumented stack reads")
STATISTIC (NumSkippedStackWrites, "Number of non-instrumented stack writes")
void createProfileFileNameVar (Module &M)
void createMemprofHistogramFlagVar (Module &M)
void createMemprofDefaultOptionsVar (Module &M)
Variables
constexpr int LLVM_MEM_PROFILER_VERSION = 1
constexpr uint64_t DefaultMemGranularity = 64
constexpr uint64_t HistogramGranularity = 8
constexpr uint64_t DefaultShadowScale = 3
constexpr char MemProfModuleCtorName [] = "memprof.module_ctor"
constexpr uint64_t MemProfCtorAndDtorPriority = 1
constexpr uint64_t MemProfEmscriptenCtorAndDtorPriority = 50
constexpr char MemProfInitName [] = "__memprof_init"
constexpr char MemProfVersionCheckNamePrefix []
constexpr char MemProfShadowMemoryDynamicAddress []
constexpr char MemProfFilenameVar [] = "__memprof_profile_filename"
constexpr char MemProfHistogramFlagVar [] = "__memprof_histogram"
static cl::opt< bool > ClInsertVersionCheck ("memprof-guard-against-version-mismatch", cl::desc("Guard against compiler/runtime version mismatch."), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInstrumentReads ("memprof-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInstrumentWrites ("memprof-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInstrumentAtomics ("memprof-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true))
static cl::opt< bool > ClUseCalls ("memprof-use-callbacks", cl::desc("Use callbacks instead of inline instrumentation sequences."), cl::Hidden, cl::init(false))
static cl::opt< std::string > ClMemoryAccessCallbackPrefix ("memprof-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__memprof_"))
static cl::opt< int > ClMappingScale ("memprof-mapping-scale", cl::desc("scale of memprof shadow mapping"), cl::Hidden, cl::init(DefaultShadowScale))
static cl::opt< int > ClMappingGranularity ("memprof-mapping-granularity", cl::desc("granularity of memprof shadow mapping"), cl::Hidden, cl::init(DefaultMemGranularity))
static cl::opt< bool > ClStack ("memprof-instrument-stack", cl::desc("Instrument scalar stack variables"), cl::Hidden, cl::init(false))
static cl::opt< int > ClDebug ("memprof-debug", cl::desc("debug"), cl::Hidden, cl::init(0))
static cl::opt< std::string > ClDebugFunc ("memprof-debug-func", cl::Hidden, cl::desc("Debug func"))
static cl::opt< int > ClDebugMin ("memprof-debug-min", cl::desc("Debug min inst"), cl::Hidden, cl::init(-1))
static cl::opt< int > ClDebugMax ("memprof-debug-max", cl::desc("Debug max inst"), cl::Hidden, cl::init(-1))
static cl::opt< bool > ClHistogram ("memprof-histogram", cl::desc("Collect access count histograms"), cl::Hidden, cl::init(false))
static cl::opt< std::string > MemprofRuntimeDefaultOptions ("memprof-runtime-default-options", cl::desc("The default memprof options"), cl::Hidden, cl::init(""))

DEBUG_TYPE

#define DEBUG_TYPE "memprof"

createMemprofDefaultOptionsVar()

void createMemprofDefaultOptionsVar ( Module & M )

createMemprofHistogramFlagVar()

void createMemprofHistogramFlagVar ( Module & M )

createProfileFileNameVar()

void createProfileFileNameVar ( Module & M )

Definition at line 474 of file MemProfInstrumentation.cpp.

References assert(), llvm::dyn_cast_or_null(), llvm::StringRef::empty(), llvm::GlobalValue::ExternalLinkage, llvm::ConstantDataArray::getString(), llvm::MDString::getString(), llvm::Value::getType(), MemProfFilenameVar, llvm::GlobalObject::setComdat(), llvm::GlobalValue::setLinkage(), and llvm::GlobalValue::WeakAnyLinkage.

STATISTIC() [1/4]

STATISTIC ( NumInstrumentedReads ,
"Number of instrumented reads" )

STATISTIC() [2/4]

STATISTIC ( NumInstrumentedWrites ,
"Number of instrumented writes" )

STATISTIC() [3/4]

STATISTIC ( NumSkippedStackReads ,
"Number of non-instrumented stack reads" )

STATISTIC() [4/4]

STATISTIC ( NumSkippedStackWrites ,
"Number of non-instrumented stack writes" )

ClDebug

cl::opt< int > ClDebug("memprof-debug", cl::desc("debug"), cl::Hidden, cl::init(0)) ( "memprof-debug" , cl::desc("debug") , cl::Hidden , cl::init(0) ) static

ClDebugFunc

ClDebugMax

cl::opt< int > ClDebugMax("memprof-debug-max", cl::desc("Debug max inst"), cl::Hidden, cl::init(-1)) ( "memprof-debug-max" , cl::desc("Debug max inst") , cl::Hidden , cl::init(-1) ) static

ClDebugMin

cl::opt< int > ClDebugMin("memprof-debug-min", cl::desc("Debug min inst"), cl::Hidden, cl::init(-1)) ( "memprof-debug-min" , cl::desc("Debug min inst") , cl::Hidden , cl::init(-1) ) static

ClHistogram

cl::opt< bool > ClHistogram("memprof-histogram", cl::desc("Collect access count histograms"), cl::Hidden, cl::init(false)) ( "memprof-histogram" , cl::desc("Collect access count histograms") , cl::Hidden , cl::init(false) ) static

ClInsertVersionCheck

cl::opt< bool > ClInsertVersionCheck("memprof-guard-against-version-mismatch", cl::desc("Guard against compiler/runtime version mismatch."), cl::Hidden, cl::init(true)) ( "memprof-guard-against-version-mismatch" , cl::desc("Guard against compiler/runtime version mismatch.") , cl::Hidden , cl::init(true) ) static

ClInstrumentAtomics

ClInstrumentReads

cl::opt< bool > ClInstrumentReads("memprof-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true)) ( "memprof-instrument-reads" , cl::desc("instrument read instructions") , cl::Hidden , cl::init(true) ) static

ClInstrumentWrites

ClMappingGranularity

cl::opt< int > ClMappingGranularity("memprof-mapping-granularity", cl::desc("granularity of memprof shadow mapping"), cl::Hidden, cl::init(DefaultMemGranularity)) ( "memprof-mapping-granularity" , cl::desc("granularity of memprof shadow mapping") , cl::Hidden , cl::init(DefaultMemGranularity) ) static

ClMappingScale

cl::opt< int > ClMappingScale("memprof-mapping-scale", cl::desc("scale of memprof shadow mapping"), cl::Hidden, cl::init(DefaultShadowScale)) ( "memprof-mapping-scale" , cl::desc("scale of memprof shadow mapping") , cl::Hidden , cl::init(DefaultShadowScale) ) static

ClMemoryAccessCallbackPrefix

cl::opt< std::string > ClMemoryAccessCallbackPrefix("memprof-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__memprof_")) ( "memprof-memory-access-callback-prefix" , cl::desc("Prefix for memory access callbacks") , cl::Hidden , cl::init("__memprof_") ) static

ClStack

cl::opt< bool > ClStack("memprof-instrument-stack", cl::desc("Instrument scalar stack variables"), cl::Hidden, cl::init(false)) ( "memprof-instrument-stack" , cl::desc("Instrument scalar stack variables") , cl::Hidden , cl::init(false) ) static

ClUseCalls

DefaultMemGranularity

DefaultShadowScale

HistogramGranularity

LLVM_MEM_PROFILER_VERSION

int LLVM_MEM_PROFILER_VERSION = 1 constexpr

MemProfCtorAndDtorPriority

MemProfEmscriptenCtorAndDtorPriority

uint64_t MemProfEmscriptenCtorAndDtorPriority = 50 constexpr

MemProfFilenameVar

char MemProfFilenameVar[] = "__memprof_profile_filename" constexpr

MemProfHistogramFlagVar

char MemProfHistogramFlagVar[] = "__memprof_histogram" constexpr

MemProfInitName

char MemProfInitName[] = "__memprof_init" constexpr

MemProfModuleCtorName

char MemProfModuleCtorName[] = "memprof.module_ctor" constexpr

MemprofRuntimeDefaultOptions

cl::opt< std::string > MemprofRuntimeDefaultOptions("memprof-runtime-default-options", cl::desc("The default memprof options"), cl::Hidden, cl::init("")) ( "memprof-runtime-default-options" , cl::desc("The default memprof options") , cl::Hidden , cl::init("") ) static

MemProfShadowMemoryDynamicAddress

char MemProfShadowMemoryDynamicAddress[] constexpr

MemProfVersionCheckNamePrefix

char MemProfVersionCheckNamePrefix[] constexpr