51#define DEBUG_TYPE "memprof"
73 "__memprof_version_mismatch_check_v";
76 "__memprof_shadow_memory_dynamic_address";
83 "memprof-guard-against-version-mismatch",
89 cl::desc(
"instrument read instructions"),
98 "memprof-instrument-atomics",
103 "memprof-use-callbacks",
104 cl::desc(
"Use callbacks instead of inline instrumentation sequences."),
109 cl::desc(
"Prefix for memory access callbacks"),
117 cl::desc(
"scale of memprof shadow mapping"),
122 cl::desc(
"granularity of memprof shadow mapping"),
126 cl::desc(
"Instrument scalar stack variables"),
143STATISTIC(NumInstrumentedReads,
"Number of instrumented reads");
144STATISTIC(NumInstrumentedWrites,
"Number of instrumented writes");
145STATISTIC(NumSkippedStackReads,
"Number of non-instrumented stack reads");
146STATISTIC(NumSkippedStackWrites,
"Number of non-instrumented stack writes");
147STATISTIC(NumOfMemProfMissing,
"Number of functions without memory profile.");
153struct ShadowMapping {
157 Mask = ~(Granularity - 1);
170struct InterestingMemoryAccess {
175 Value *MaybeMask =
nullptr;
182 C = &(
M.getContext());
183 LongSize =
M.getDataLayout().getPointerSizeInBits();
190 std::optional<InterestingMemoryAccess>
194 InterestingMemoryAccess &Access);
203 bool maybeInsertMemProfInitAtFunctionEntry(
Function &
F);
204 bool insertDynamicShadowAtFunctionEntry(
Function &
F);
207 void initializeCallbacks(
Module &M);
212 ShadowMapping Mapping;
219 Value *DynamicShadowOffset =
nullptr;
222class ModuleMemProfiler {
224 ModuleMemProfiler(
Module &M) { TargetTriple =
Triple(
M.getTargetTriple()); }
226 bool instrumentModule(
Module &);
230 ShadowMapping Mapping;
231 Function *MemProfCtorFunction =
nullptr;
241 MemProfiler Profiler(M);
242 if (Profiler.instrumentFunction(
F))
251 ModuleMemProfiler Profiler(M);
252 if (Profiler.instrumentModule(M))
259 Shadow = IRB.
CreateAnd(Shadow, Mapping.Mask);
260 Shadow = IRB.
CreateLShr(Shadow, Mapping.Scale);
262 assert(DynamicShadowOffset);
263 return IRB.
CreateAdd(Shadow, DynamicShadowOffset);
269 if (isa<MemTransferInst>(
MI)) {
271 isa<MemMoveInst>(
MI) ? MemProfMemmove : MemProfMemcpy,
275 }
else if (isa<MemSetInst>(
MI)) {
282 MI->eraseFromParent();
285std::optional<InterestingMemoryAccess>
286MemProfiler::isInterestingMemoryAccess(
Instruction *
I)
const {
288 if (DynamicShadowOffset ==
I)
291 InterestingMemoryAccess Access;
293 if (
LoadInst *LI = dyn_cast<LoadInst>(
I)) {
296 Access.IsWrite =
false;
297 Access.AccessTy = LI->getType();
298 Access.Addr = LI->getPointerOperand();
299 }
else if (
StoreInst *SI = dyn_cast<StoreInst>(
I)) {
302 Access.IsWrite =
true;
303 Access.AccessTy =
SI->getValueOperand()->getType();
304 Access.Addr =
SI->getPointerOperand();
308 Access.IsWrite =
true;
309 Access.AccessTy = RMW->getValOperand()->getType();
310 Access.Addr = RMW->getPointerOperand();
314 Access.IsWrite =
true;
315 Access.AccessTy = XCHG->getCompareOperand()->getType();
316 Access.Addr = XCHG->getPointerOperand();
317 }
else if (
auto *CI = dyn_cast<CallInst>(
I)) {
318 auto *
F = CI->getCalledFunction();
319 if (
F && (
F->getIntrinsicID() == Intrinsic::masked_load ||
320 F->getIntrinsicID() == Intrinsic::masked_store)) {
321 unsigned OpOffset = 0;
322 if (
F->getIntrinsicID() == Intrinsic::masked_store) {
327 Access.AccessTy = CI->getArgOperand(0)->getType();
328 Access.IsWrite =
true;
332 Access.AccessTy = CI->getType();
333 Access.IsWrite =
false;
336 auto *
BasePtr = CI->getOperand(0 + OpOffset);
337 Access.MaybeMask = CI->getOperand(2 + OpOffset);
347 Type *PtrTy = cast<PointerType>(Access.Addr->getType()->getScalarType());
355 if (Access.Addr->isSwiftError())
359 auto *
Addr = Access.Addr->stripInBoundsOffsets();
363 if (GV->hasSection()) {
373 if (GV->getName().startswith(
"__llvm"))
378 Access.TypeSize =
DL.getTypeStoreSizeInBits(Access.AccessTy);
384 Type *AccessTy,
bool IsWrite) {
385 auto *VTy = cast<FixedVectorType>(AccessTy);
386 uint64_t ElemTypeSize =
DL.getTypeStoreSizeInBits(VTy->getScalarType());
387 unsigned Num = VTy->getNumElements();
389 for (
unsigned Idx = 0;
Idx < Num; ++
Idx) {
390 Value *InstrumentedAddress =
nullptr;
392 if (
auto *
Vector = dyn_cast<ConstantVector>(Mask)) {
394 if (
auto *Masked = dyn_cast<ConstantInt>(
Vector->getOperand(
Idx))) {
395 if (Masked->isZero())
405 InsertBefore = ThenTerm;
409 InstrumentedAddress =
411 instrumentAddress(
I, InsertBefore, InstrumentedAddress, ElemTypeSize,
417 InterestingMemoryAccess &Access) {
421 ++NumSkippedStackWrites;
423 ++NumSkippedStackReads;
428 NumInstrumentedWrites++;
430 NumInstrumentedReads++;
432 if (Access.MaybeMask) {
433 instrumentMaskedLoadOrStore(
DL, Access.MaybeMask,
I, Access.Addr,
434 Access.AccessTy, Access.IsWrite);
439 instrumentAddress(
I,
I, Access.Addr, Access.TypeSize, Access.IsWrite);
443void MemProfiler::instrumentAddress(
Instruction *OrigIns,
450 IRB.
CreateCall(MemProfMemoryAccessCallback[IsWrite], AddrLong);
458 Value *ShadowPtr = memToShadow(AddrLong, IRB);
462 ShadowValue = IRB.
CreateAdd(ShadowValue, Inc);
469 dyn_cast_or_null<MDString>(M.getModuleFlag(
"MemProfProfileFilename"));
470 if (!MemProfFilename)
473 "Unexpected MemProfProfileFilename metadata with empty string");
475 M.getContext(), MemProfFilename->
getString(),
true);
477 M, ProfileNameConst->
getType(),
true,
479 Triple TT(M.getTargetTriple());
480 if (TT.supportsCOMDAT()) {
486bool ModuleMemProfiler::instrumentModule(
Module &M) {
489 std::string VersionCheckName =
492 std::tie(MemProfCtorFunction, std::ignore) =
495 {}, VersionCheckName);
497 const uint64_t Priority = getCtorAndDtorPriority(TargetTriple);
505void MemProfiler::initializeCallbacks(
Module &M) {
508 for (
size_t AccessIsWrite = 0; AccessIsWrite <= 1; AccessIsWrite++) {
509 const std::string TypeStr = AccessIsWrite ?
"store" :
"load";
513 MemProfMemoryAccessCallbackSized[AccessIsWrite] =
517 MemProfMemoryAccessCallback[AccessIsWrite] =
521 MemProfMemmove =
M.getOrInsertFunction(
532bool MemProfiler::maybeInsertMemProfInitAtFunctionEntry(
Function &
F) {
540 if (
F.getName().find(
" load]") != std::string::npos) {
550bool MemProfiler::insertDynamicShadowAtFunctionEntry(
Function &
F) {
552 Value *GlobalDynamicAddress =
F.getParent()->getOrInsertGlobal(
555 cast<GlobalVariable>(GlobalDynamicAddress)->setDSOLocal(
true);
556 DynamicShadowOffset = IRB.
CreateLoad(IntptrTy, GlobalDynamicAddress);
560bool MemProfiler::instrumentFunction(
Function &
F) {
565 if (
F.getName().startswith(
"__memprof_"))
568 bool FunctionModified =
false;
573 if (maybeInsertMemProfInitAtFunctionEntry(
F))
574 FunctionModified =
true;
578 initializeCallbacks(*
F.getParent());
584 for (
auto &Inst : BB) {
585 if (isInterestingMemoryAccess(&Inst) || isa<MemIntrinsic>(Inst))
590 if (ToInstrument.
empty()) {
591 LLVM_DEBUG(
dbgs() <<
"MEMPROF done instrumenting: " << FunctionModified
592 <<
" " <<
F <<
"\n");
594 return FunctionModified;
597 FunctionModified |= insertDynamicShadowAtFunctionEntry(
F);
599 int NumInstrumented = 0;
600 for (
auto *Inst : ToInstrument) {
603 std::optional<InterestingMemoryAccess> Access =
604 isInterestingMemoryAccess(Inst);
606 instrumentMop(Inst,
F.getParent()->getDataLayout(), *Access);
608 instrumentMemIntrinsic(cast<MemIntrinsic>(Inst));
613 if (NumInstrumented > 0)
614 FunctionModified =
true;
616 LLVM_DEBUG(
dbgs() <<
"MEMPROF done instrumenting: " << FunctionModified <<
" "
619 return FunctionModified;
623 std::vector<uint64_t> &InlinedCallStack,
625 I.setMetadata(LLVMContext::MD_callsite,
636 std::memcpy(&Id, Hash.data(),
sizeof(Hash));
647 for (
const auto &StackFrame :
AllocInfo->CallStack)
662 unsigned StartIndex = 0) {
663 auto StackFrame = ProfileCallStack.
begin() + StartIndex;
664 auto InlCallStackIter = InlinedCallStack.
begin();
665 for (; StackFrame != ProfileCallStack.
end() &&
666 InlCallStackIter != InlinedCallStack.
end();
667 ++StackFrame, ++InlCallStackIter) {
669 if (StackId != *InlCallStackIter)
674 return InlCallStackIter == InlinedCallStack.
end();
680 auto &Ctx = M.getContext();
684 std::optional<memprof::MemProfRecord> MemProfRec;
685 auto Err =
MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
691 return make_error<InstrProfError>(IE);
695 MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec))
702 auto Err = IPE.
get();
703 bool SkipWarning =
false;
704 LLVM_DEBUG(
dbgs() <<
"Error in reading profile for Func " << FuncName
707 NumOfMemProfMissing++;
716 LLVM_DEBUG(
dbgs() <<
"hash mismatch (skip=" << SkipWarning <<
")");
722 std::string Msg = (IPE.
message() +
Twine(
" ") +
F.getName().str() +
723 Twine(
" Hash = ") + std::to_string(FuncGUID))
734 std::map<uint64_t, std::set<const AllocationInfo *>> LocHashToAllocInfo;
737 std::map<uint64_t, std::set<std::pair<const SmallVector<Frame> *,
unsigned>>>
739 for (
auto &AI : MemProfRec->AllocSites) {
744 LocHashToAllocInfo[StackId].insert(&AI);
746 for (
auto &CS : MemProfRec->CallSites) {
750 for (
auto &StackFrame : CS) {
752 LocHashToCallSites[StackId].insert(std::make_pair(&CS,
Idx++));
754 if (StackFrame.Function == FuncGUID)
757 assert(
Idx <= CS.size() && CS[
Idx - 1].Function == FuncGUID);
761 return (DIL->getLine() - DIL->getScope()->getSubprogram()->getLine()) &
769 if (
I.isDebugOrPseudoInst())
773 auto *CI = dyn_cast<CallBase>(&
I);
776 auto *CalledFunction = CI->getCalledFunction();
777 if (CalledFunction && CalledFunction->isIntrinsic())
781 std::vector<uint64_t> InlinedCallStack;
783 bool LeafFound =
false;
789 std::map<uint64_t, std::set<const AllocationInfo *>>::iterator
791 std::map<uint64_t, std::set<std::pair<const SmallVector<Frame> *,
792 unsigned>>>::iterator CallSitesIter;
793 for (
const DILocation *DIL =
I.getDebugLoc(); DIL !=
nullptr;
794 DIL = DIL->getInlinedAt()) {
797 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
799 Name = DIL->getScope()->getSubprogram()->getName();
806 AllocInfoIter = LocHashToAllocInfo.find(StackId);
807 CallSitesIter = LocHashToCallSites.find(StackId);
810 if (AllocInfoIter == LocHashToAllocInfo.end() &&
811 CallSitesIter == LocHashToCallSites.end())
815 InlinedCallStack.push_back(StackId);
825 if (AllocInfoIter != LocHashToAllocInfo.end()) {
834 for (
auto *
AllocInfo : AllocInfoIter->second) {
845 if (!AllocTrie.
empty()) {
849 assert(MemprofMDAttached ==
I.hasMetadata(LLVMContext::MD_memprof));
850 if (MemprofMDAttached) {
867 assert(CallSitesIter != LocHashToCallSites.end());
868 for (
auto CallStackIdx : CallSitesIter->second) {
872 *CallStackIdx.first, InlinedCallStack, CallStackIdx.second)) {
885 : MemoryProfileFileName(MemoryProfileFile), FS(FS) {
892 auto &Ctx = M.getContext();
894 if (
Error E = ReaderOrErr.takeError()) {
903 std::move(ReaderOrErr.get());
906 MemoryProfileFileName.data(),
StringRef(
"Cannot get MemProfReader")));
912 "Not a memory profile"));
919 if (
F.isDeclaration())
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< int > ClDebugMin("asan-debug-min", cl::desc("Debug min inst"), cl::Hidden, cl::init(-1))
static cl::opt< std::string > ClMemoryAccessCallbackPrefix("asan-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__asan_"))
static cl::opt< bool > ClInsertVersionCheck("asan-guard-against-version-mismatch", cl::desc("Guard against compiler/runtime version mismatch."), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInstrumentWrites("asan-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true))
static cl::opt< int > ClDebugMax("asan-debug-max", cl::desc("Debug max inst"), cl::Hidden, cl::init(-1))
static cl::opt< bool > ClStack("asan-stack", cl::desc("Handle stack memory"), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInstrumentAtomics("asan-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true))
static cl::opt< int > ClMappingScale("asan-mapping-scale", cl::desc("scale of asan shadow mapping"), cl::Hidden, cl::init(0))
static cl::opt< std::string > ClDebugFunc("asan-debug-func", cl::Hidden, cl::desc("Debug func"))
static cl::opt< bool > ClInstrumentReads("asan-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
constexpr char MemProfVersionCheckNamePrefix[]
static cl::opt< int > ClDebugMin("memprof-debug-min", cl::desc("Debug min inst"), cl::Hidden, cl::init(-1))
constexpr uint64_t MemProfEmscriptenCtorAndDtorPriority
static cl::opt< std::string > ClDebugFunc("memprof-debug-func", cl::Hidden, cl::desc("Debug func"))
constexpr char MemProfShadowMemoryDynamicAddress[]
static void addCallStack(CallStackTrie &AllocTrie, const AllocationInfo *AllocInfo)
constexpr uint64_t MemProfCtorAndDtorPriority
constexpr int LLVM_MEM_PROFILER_VERSION
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< bool > ClInstrumentAtomics("memprof-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true))
static cl::opt< bool > ClInsertVersionCheck("memprof-guard-against-version-mismatch", cl::desc("Guard against compiler/runtime version mismatch."), cl::Hidden, cl::init(true))
constexpr char MemProfInitName[]
constexpr char MemProfFilenameVar[]
static uint64_t computeStackId(GlobalValue::GUID Function, uint32_t LineOffset, uint32_t Column)
static cl::opt< bool > ClStack("memprof-instrument-stack", cl::desc("Instrument scalar stack variables"), cl::Hidden, cl::init(false))
constexpr uint64_t DefaultShadowGranularity
constexpr uint64_t DefaultShadowScale
static cl::opt< std::string > ClMemoryAccessCallbackPrefix("memprof-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__memprof_"))
constexpr char MemProfModuleCtorName[]
static cl::opt< bool > ClInstrumentReads("memprof-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true))
static cl::opt< int > ClDebugMax("memprof-debug-max", cl::desc("Debug max inst"), cl::Hidden, cl::init(-1))
static void readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
static cl::opt< bool > ClInstrumentWrites("memprof-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true))
static cl::opt< int > ClDebug("memprof-debug", cl::desc("debug"), cl::Hidden, cl::init(0))
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(DefaultShadowGranularity))
static void addCallsiteMetadata(Instruction &I, std::vector< uint64_t > &InlinedCallStack, LLVMContext &Ctx)
static bool stackFrameIncludesInlinedCallStack(ArrayRef< Frame > ProfileCallStack, ArrayRef< uint64_t > InlinedCallStack, unsigned StartIndex=0)
Module.h This file contains the declarations for the Module class.
FunctionAnalysisManager FAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Defines the virtual file system interface vfs::FileSystem.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Diagnostic information for the PGO profiler.
Base class for error info classes.
virtual std::string message() const
Return the error message as a string.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
void setComdat(Comdat *C)
void setLinkage(LinkageTypes LT)
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AvailableExternallyLinkage
Available for inspection, not emission.
HashResultTy< HasherT_ > final()
Forward to HasherT::final() if available.
Implementation of the HashBuilder interface.
std::enable_if_t< hashbuilder_detail::IsHashableData< T >::value, HashBuilderImpl & > add(T Value)
Implement hashing for hashable data types, e.g. integral or enum values.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Type * getVoidTy()
Fetch the type representing void.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", bool IsInBounds=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Reader for the indexed binary instrprof format.
static Expected< std::unique_ptr< IndexedInstrProfReader > > create(const Twine &Path, vfs::FileSystem &FS, const Twine &RemappingPath="")
Factory method to create an indexed reader.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
instrprof_error get() const
std::string message() const override
Return the error message as a string.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
StringRef getString() const
This is the common base class for memset/memcpy/memmove.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
MemProfUsePass(std::string MemoryProfileFile, IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
A Module instance is used to store all the information related to an LLVM module.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
Triple - Helper class for working with autoconf configuration names.
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static IntegerType * getInt64Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
Class to build a trie of call stack contexts for a particular profiled allocation call,...
void addCallStack(AllocationType AllocType, ArrayRef< uint64_t > StackIds)
Add a call stack context with the given allocation type to the Trie.
bool buildAndAttachMIBMetadata(CallBase *CI)
Build and attach the minimal necessary MIB metadata.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
MDNode * buildCallstackMetadata(ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)
Build callstack metadata from the provided list of call stack ids.
AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)
Return the allocation type for a given set of memory profile values.
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
std::string getPGOFuncName(const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Return the modified name for function F suitable to be used the key for profile lookup.
std::string getIRPGOFuncName(const Function &F, bool InLTO=false)
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value,...
cl::opt< bool > PGOWarnMissing
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
std::array< uint8_t, NumBytes > BLAKE3Result
The constant LLVM_BLAKE3_OUT_LEN provides the default output length, 32 bytes, which is recommended f...
FunctionCallee declareSanitizerInitFunction(Module &M, StringRef InitName, ArrayRef< Type * > InitArgTypes, bool Weak=false)
std::pair< Function *, FunctionCallee > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, StringRef VersionCheckName=StringRef(), bool Weak=false)
Creates sanitizer constructor function, and calls sanitizer's init function from it.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
HashBuilderImpl< HasherT,(Endianness==support::endianness::native ? support::endian::system_endianness() :Endianness)> HashBuilder
Interface to help hash various types through a hasher type.
cl::opt< bool > NoPGOWarnMismatch
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
bool isNewLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates memory via new.
cl::opt< bool > NoPGOWarnMismatchComdatWeak
Summary of memprof metadata on allocations.
GlobalValue::GUID Function