LLVM  14.0.0git
Macros | Functions | Variables
MemProfiler.cpp File Reference
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Include dependency graph for MemProfiler.cpp:

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")
 
 INITIALIZE_PASS_BEGIN (MemProfilerLegacyPass, "memprof", "MemProfiler: profile memory allocations and accesses.", false, false) INITIALIZE_PASS_END(MemProfilerLegacyPass
 
 INITIALIZE_PASS (ModuleMemProfilerLegacyPass, "memprof-module", "MemProfiler: profile memory allocations and accesses." "ModulePass", false, false) ModulePass *llvm
 
void createProfileFileNameVar (Module &M)
 

Variables

constexpr int LLVM_MEM_PROFILER_VERSION = 1
 
constexpr uint64_t DefaultShadowGranularity = 64
 
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"
 
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< intClMappingScale ("memprof-mapping-scale", cl::desc("scale of memprof shadow mapping"), cl::Hidden, cl::init(DefaultShadowScale))
 
static cl::opt< intClMappingGranularity ("memprof-mapping-granularity", cl::desc("granularity of memprof shadow mapping"), cl::Hidden, cl::init(DefaultShadowGranularity))
 
static cl::opt< bool > ClStack ("memprof-instrument-stack", cl::desc("Instrument scalar stack variables"), cl::Hidden, cl::init(false))
 
static cl::opt< intClDebug ("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< intClDebugMin ("memprof-debug-min", cl::desc("Debug min inst"), cl::Hidden, cl::init(-1))
 
static cl::opt< intClDebugMax ("memprof-debug-max", cl::desc("Debug max inst"), cl::Hidden, cl::init(-1))
 
 memprof
 
MemProfiler __pad0__
 
MemProfiler false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "memprof"

Definition at line 43 of file MemProfiler.cpp.

Function Documentation

◆ createProfileFileNameVar()

void createProfileFileNameVar ( Module M)

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( ModuleMemProfilerLegacyPass  ,
"memprof-module"  ,
"MemProfiler: profile memory allocations and accesses." "ModulePass ,
false  ,
false   
)

Definition at line 292 of file MemProfiler.cpp.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( MemProfilerLegacyPass  ,
"memprof"  ,
"MemProfiler: profile memory allocations and accesses."  ,
false  ,
false   
)

◆ 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"   
)

Variable Documentation

◆ __pad0__

MemProfiler __pad0__

Definition at line 283 of file MemProfiler.cpp.

◆ ClDebug

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

◆ ClDebugFunc

cl::opt<std::string> ClDebugFunc("memprof-debug-func", cl::Hidden, cl::desc("Debug func"))
static

◆ ClDebugMax

cl::opt<int> ClDebugMax("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))
static

◆ ClInsertVersionCheck

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

◆ ClInstrumentAtomics

cl::opt<bool> ClInstrumentAtomics("memprof-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true))
static

◆ ClInstrumentReads

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

◆ ClInstrumentWrites

cl::opt<bool> ClInstrumentWrites("memprof-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true))
static

◆ ClMappingGranularity

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

◆ ClMappingScale

cl::opt<int> ClMappingScale("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_"))
static

◆ ClStack

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

◆ ClUseCalls

cl::opt<bool> ClUseCalls("memprof-use-callbacks", cl::desc("Use callbacks instead of inline instrumentation sequences."), cl::Hidden, cl::init(false))
static

◆ DefaultShadowGranularity

constexpr uint64_t DefaultShadowGranularity = 64
constexpr

Definition at line 48 of file MemProfiler.cpp.

◆ DefaultShadowScale

constexpr uint64_t DefaultShadowScale = 3
constexpr

Definition at line 51 of file MemProfiler.cpp.

◆ false

MemProfiler false

Definition at line 284 of file MemProfiler.cpp.

◆ LLVM_MEM_PROFILER_VERSION

constexpr int LLVM_MEM_PROFILER_VERSION = 1
constexpr

Definition at line 45 of file MemProfiler.cpp.

◆ memprof

memprof

Definition at line 282 of file MemProfiler.cpp.

◆ MemProfCtorAndDtorPriority

constexpr uint64_t MemProfCtorAndDtorPriority = 1
constexpr

Definition at line 54 of file MemProfiler.cpp.

◆ MemProfEmscriptenCtorAndDtorPriority

constexpr uint64_t MemProfEmscriptenCtorAndDtorPriority = 50
constexpr

Definition at line 56 of file MemProfiler.cpp.

◆ MemProfFilenameVar

constexpr char MemProfFilenameVar[] = "__memprof_profile_filename"
constexpr

Definition at line 64 of file MemProfiler.cpp.

Referenced by createProfileFileNameVar().

◆ MemProfInitName

constexpr char MemProfInitName[] = "__memprof_init"
constexpr

Definition at line 57 of file MemProfiler.cpp.

◆ MemProfModuleCtorName

constexpr char MemProfModuleCtorName[] = "memprof.module_ctor"
constexpr

Definition at line 53 of file MemProfiler.cpp.

◆ MemProfShadowMemoryDynamicAddress

constexpr char MemProfShadowMemoryDynamicAddress[]
constexpr
Initial value:
=
"__memprof_shadow_memory_dynamic_address"

Definition at line 61 of file MemProfiler.cpp.

◆ MemProfVersionCheckNamePrefix

constexpr char MemProfVersionCheckNamePrefix[]
constexpr
Initial value:
=
"__memprof_version_mismatch_check_v"

Definition at line 58 of file MemProfiler.cpp.