LLVM: lib/Analysis/MemoryBuiltins.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "memory-builtins"
Enumerations
enum AllocType : uint8_t { OpNewLike = 1<<0 , MallocLike = 1<<1 , StrDupLike = 1<<2 , MallocOrOpNewLike = MallocLike | OpNewLike , AllocLike = MallocOrOpNewLike StrDupLike , AnyAlloc = AllocLike }
enum class MallocFamily { Malloc, CPPNew, CPPNewAligned, CPPNewArray, CPPNewArrayAligned, MSVCNew, MSVCArrayNew, VecMalloc, KmpcAllocShared }
Functions
StringRef mangledNameForMallocFamily (const MallocFamily &Family)
static const Function * getCalledFunction (const Value *V)
static std::optional< AllocFnsTy > getAllocationDataForFunction (const Function *Callee, AllocType AllocTy, const TargetLibraryInfo *TLI)
Returns the allocation data for the given value if it's a call to a known allocation function.
static std::optional< AllocFnsTy > getAllocationData (const Value *V, AllocType AllocTy, const TargetLibraryInfo *TLI)
static std::optional< AllocFnsTy > getAllocationData (const Value *V, AllocType AllocTy, function_ref< const TargetLibraryInfo &(Function &)> GetTLI)
static std::optional< AllocFnsTy > getAllocationSize (const CallBase *CB, const TargetLibraryInfo *TLI)
static AllocFnKind getAllocFnKind (const Value *V)
static AllocFnKind getAllocFnKind (const Function *F)
static bool checkFnAllocKind (const Value *V, AllocFnKind Wanted)
static bool checkFnAllocKind (const Function *F, AllocFnKind Wanted)
static bool CheckedZextOrTrunc (APInt &I, unsigned IntTyBits)
When we're compiling N-bit code, and the user uses parameters that are greater than N bits (e.g.
std::optional< FreeFnsTy > getFreeFunctionDataForFunction (const Function *Callee, const LibFunc TLIFn)
static APInt getSizeWithOverflow (const SizeOffsetAPInt &Data)
STATISTIC (ObjectVisitorArgument, "Number of arguments with unsolved size and offset")
STATISTIC (ObjectVisitorLoad, "Number of load instructions with unsolved size and offset")
static std::optional< APInt > combinePossibleConstantValues (std::optional< APInt > LHS, std::optional< APInt > RHS, ObjectSizeOpts::Mode EvalMode)
static std::optional< APInt > aggregatePossibleConstantValuesImpl (const Value *V, ObjectSizeOpts::Mode EvalMode, unsigned BitWidth, unsigned recursionDepth)
static std::optional< APInt > aggregatePossibleConstantValues (const Value *V, ObjectSizeOpts::Mode EvalMode, unsigned BitWidth)

DEBUG_TYPE

#define DEBUG_TYPE "memory-builtins"

AllocType

Enumerator
OpNewLike
MallocLike
StrDupLike
MallocOrOpNewLike
AllocLike
AnyAlloc

Definition at line 59 of file MemoryBuiltins.cpp.

MallocFamily

Enumerator
Malloc
CPPNew
CPPNewAligned
CPPNewArray
CPPNewArrayAligned
MSVCNew
MSVCArrayNew
VecMalloc
KmpcAllocShared

Definition at line 68 of file MemoryBuiltins.cpp.

aggregatePossibleConstantValues()

aggregatePossibleConstantValuesImpl()

CheckedZextOrTrunc()

When we're compiling N-bit code, and the user uses parameters that are greater than N bits (e.g.

uint64_t on a 32-bit build), we can run into trouble with APInt size issues. This function handles resizing + overflow checks for us. Check and zext or trunc I depending on IntTyBits and I's value.

Definition at line 355 of file MemoryBuiltins.cpp.

References I.

Referenced by llvm::getAllocSize().

checkFnAllocKind() [1/2]

checkFnAllocKind() [2/2]

combinePossibleConstantValues()

getAllocationData() [1/2]

getAllocationData() [2/2]

getAllocationDataForFunction()

Returns the allocation data for the given value if it's a call to a known allocation function.

Definition at line 177 of file MemoryBuiltins.cpp.

References AllocationFnData, AllocFnsTy::AllocTy, llvm::find_if(), AllocFnsTy::FstParam, llvm::TargetLibraryInfo::getLibFunc(), llvm::TargetLibraryInfo::has(), AllocFnsTy::NumParams, P, and AllocFnsTy::SndParam.

Referenced by getAllocationData(), getAllocationData(), llvm::getAllocationFamily(), and getAllocationSize().

getAllocationSize()

getAllocFnKind() [1/2]

getAllocFnKind() [2/2]

getCalledFunction()

Definition at line 159 of file MemoryBuiltins.cpp.

References llvm::dyn_cast(), and llvm::isa().

Referenced by llvm::orc::SpeculateQuery::findCalles(), FindPreallocatedCall(), getAllocationData(), getAllocationData(), llvm::getAllocationFamily(), getAllocationSize(), llvm::getFreedOperand(), llvm::AArch64TTIImpl::getUnrollingPreferences(), llvm::ARMTTIImpl::getUnrollingPreferences(), llvm::BasicTTIImplBase< BasicTTIImpl >::getUnrollingPreferences(), llvm::RISCVTTIImpl::getUnrollingPreferences(), llvm::SystemZTTIImpl::getUnrollingPreferences(), llvm::WebAssemblyTTIImpl::getUnrollingPreferences(), llvm::InlineAdvice::InlineAdvice(), isNoReturnDef(), and llvm::InstCombinerImpl::visitCallInst().

getFreeFunctionDataForFunction()

getSizeWithOverflow()

mangledNameForMallocFamily()

STATISTIC() [1/2]

STATISTIC ( ObjectVisitorArgument ,
"Number of arguments with unsolved size and offset" )

STATISTIC() [2/2]

STATISTIC ( ObjectVisitorLoad ,
"Number of load instructions with unsolved size and offset" )

AllocationFnData

FreeFnData

ObjectSizeOffsetVisitorMaxVisitInstructions