15 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H 16 #define LLVM_ANALYSIS_MEMORYBUILTINS_H 35 class ConstantPointerNull;
37 class ExtractElementInst;
38 class ExtractValueInst;
51 class TargetLibraryInfo;
60 bool LookThroughBitCast =
false);
64 bool isNoAliasFn(
const Value *V,
const TargetLibraryInfo *TLI,
65 bool LookThroughBitCast =
false);
70 bool LookThroughBitCast =
false);
75 bool LookThroughBitCast =
false);
80 bool LookThroughBitCast =
false);
84 bool isAllocLikeFn(
const Value *V,
const TargetLibraryInfo *TLI,
85 bool LookThroughBitCast =
false);
120 bool LookThroughSExt =
false);
195 :
public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
216 return SizeOffset.first.getBitWidth() > 1;
220 return SizeOffset.second.getBitWidth() > 1;
224 return knownSize(SizeOffset) && knownOffset(SizeOffset);
246 bool CheckedZextOrTrunc(
APInt &I);
254 :
public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
256 using WeakEvalType = std::pair<WeakTrackingVH, WeakTrackingVH>;
271 return std::make_pair(
nullptr,
nullptr);
283 return SizeOffset.first;
287 return SizeOffset.second;
291 return knownSize(SizeOffset) || knownOffset(SizeOffset);
295 return knownSize(SizeOffset) && knownOffset(SizeOffset);
313 #endif // LLVM_ANALYSIS_MEMORYBUILTINS_H bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, ObjectSizeOpts Opts={})
Compute the size of the object pointed by Ptr.
bool isAllocationFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates or reallocates memory (eith...
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
This class represents an incoming formal argument to a Function.
Base class for instruction visitors.
This class represents lattice values for constants.
const CallInst * extractCallocCall(const Value *I, const TargetLibraryInfo *TLI)
extractCallocCall - Returns the corresponding CallInst if the instruction is a calloc call...
std::pair< Value *, Value * > SizeOffsetEvalType
static bool knownSize(const SizeOffsetType &SizeOffset)
bool NullIsUnknownSize
If this is true, null pointers in address space 0 will be treated as though they can't be evaluated...
This class represents a function call, abstracting a target machine's calling convention.
bool RoundToAlign
Whether to round the result up to the alignment of allocas, byval arguments, and global variables...
An instruction for reading from memory.
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
This class represents the LLVM 'select' instruction.
'undef' values are things that do not have specified contents.
bool knownSize(SizeOffsetEvalType SizeOffset)
This file implements a class to represent arbitrary precision integral constant values and operations...
bool isNoAliasFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a function that returns a NoAlias pointer (including malloc/c...
Same as Min, except we pick the maximum size of all of the branches.
Evaluate all branches of an unknown condition.
Evaluate the size and offset of an object pointed to by a Value*.
Class to represent pointers.
Value * getMallocArraySize(CallInst *CI, const DataLayout &DL, const TargetLibraryInfo *TLI, bool LookThroughSExt=false)
getMallocArraySize - Returns the array size of a malloc call.
ConstantInt * lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL, const TargetLibraryInfo *TLI, bool MustSucceed)
Try to turn a call to @llvm.objectsize into an integer value of the given Type.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
const CallInst * extractMallocCall(const Value *I, const TargetLibraryInfo *TLI)
extractMallocCall - Returns the corresponding CallInst if the instruction is a malloc call...
Class to represent integer types.
This class represents a cast from an integer to a pointer.
std::pair< APInt, APInt > SizeOffsetType
PointerType * getMallocType(const CallInst *CI, const TargetLibraryInfo *TLI)
getMallocType - Returns the PointerType resulting from the malloc call.
Mode EvalMode
How we want to evaluate this object's size.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
Evaluate the size and offset of an object pointed to by a Value* statically.
static bool knownOffset(const SizeOffsetType &SizeOffset)
Provides information about what library functions are available for the current target.
A constant pointer value that points to null.
Class for arbitrary precision integers.
Type * getMallocAllocatedType(const CallInst *CI, const TargetLibraryInfo *TLI)
getMallocAllocatedType - Returns the Type allocated by malloc call.
bool isMallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates uninitialized memory (such ...
Fail to evaluate an unknown condition.
bool isMallocOrCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates memory similar to malloc or...
bool isCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates zero-filled memory (such as...
bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates memory (either malloc...
bool knownOffset(SizeOffsetEvalType SizeOffset)
bool anyKnown(SizeOffsetEvalType SizeOffset)
static bool bothKnown(const SizeOffsetType &SizeOffset)
LLVM Value Representation.
Mode
Controls how we handle conditional statements with unknown conditions.
Various options to control the behavior of getObjectSize.
bool bothKnown(SizeOffsetEvalType SizeOffset)
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack