15 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H
16 #define LLVM_ANALYSIS_MEMORYBUILTINS_H
25 #include "llvm/Support/DataTypes.h"
31 class TargetLibraryInfo;
40 bool LookThroughBitCast =
false);
44 bool isNoAliasFn(
const Value *V,
const TargetLibraryInfo *TLI,
45 bool LookThroughBitCast =
false);
50 bool LookThroughBitCast =
false);
55 bool LookThroughBitCast =
false);
59 bool isAllocLikeFn(
const Value *V,
const TargetLibraryInfo *TLI,
60 bool LookThroughBitCast =
false);
65 bool LookThroughBitCast =
false);
70 bool LookThroughBitCast =
false);
90 PointerType *
getMallocType(
const CallInst *CI,
const TargetLibraryInfo *TLI);
105 const TargetLibraryInfo *TLI,
106 bool LookThroughSExt =
false);
126 const CallInst *
isFreeCall(
const Value *
I,
const TargetLibraryInfo *TLI);
143 bool getObjectSize(
const Value *Ptr, uint64_t &Size,
const DataLayout &DL,
144 const TargetLibraryInfo *TLI,
bool RoundToAlign =
false);
151 :
public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
173 return SizeOffset.first.getBitWidth() > 1;
177 return SizeOffset.second.getBitWidth() > 1;
209 :
public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
212 typedef std::pair<WeakVH, WeakVH> WeakEvalType;
227 return std::make_pair(
nullptr,
nullptr);
237 return SizeOffset.first;
241 return SizeOffset.second;
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. ...
LLVM Argument representation.
Base class for instruction visitors.
const CallInst * extractCallocCall(const Value *I, const TargetLibraryInfo *TLI)
extractCallocCall - Returns the corresponding CallInst if the instruction is a calloc call...
bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, bool RoundToAlign=false)
Compute the size of the object pointed by Ptr.
CallInst - This class represents a function call, abstracting a target machine's calling convention...
SizeOffsetType visitAllocaInst(AllocaInst &I)
LoadInst - an instruction for reading from memory.
bool isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that reallocates memory (such as realloc)...
SizeOffsetType visitArgument(Argument &A)
bool knownSize(SizeOffsetType &SizeOffset)
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
SelectInst - This class represents the LLVM 'select' instruction.
SizeOffsetEvalType visitGEPOperator(GEPOperator &GEP)
SizeOffsetType visitExtractValueInst(ExtractValueInst &I)
SizeOffsetType visitGEPOperator(GEPOperator &GEP)
UndefValue - 'undef' values are things that do not have specified contents.
bool knownSize(SizeOffsetEvalType SizeOffset)
bool isOperatorNewLikeFn(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 and never returns nu...
SizeOffsetEvalType visitCallSite(CallSite CS)
SizeOffsetType visitIntToPtrInst(IntToPtrInst &)
ObjectSizeOffsetEvaluator(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign=false)
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...
Evaluate the size and offset of an object pointed to by a Value*.
std::pair< APInt, APInt > SizeOffsetType
SizeOffsetType visitInstruction(Instruction &I)
Value * getMallocArraySize(CallInst *CI, const DataLayout &DL, const TargetLibraryInfo *TLI, bool LookThroughSExt=false)
getMallocArraySize - Returns the array size of a malloc call.
SizeOffsetType visitGlobalVariable(GlobalVariable &GV)
SizeOffsetEvalType visitSelectInst(SelectInst &I)
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.
SizeOffsetType visitCallSite(CallSite CS)
PointerType * getMallocType(const CallInst *CI, const TargetLibraryInfo *TLI)
getMallocType - Returns the PointerType resulting from the malloc call.
SizeOffsetType visitSelectInst(SelectInst &I)
SizeOffsetType visitExtractElementInst(ExtractElementInst &I)
SizeOffsetType visitGlobalAlias(GlobalAlias &GA)
SizeOffsetEvalType visitInstruction(Instruction &I)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign=false)
Evaluate the size and offset of an object pointed to by a Value* statically.
Provides information about what library functions are available for the current target.
SizeOffsetType visitPHINode(PHINode &)
ConstantPointerNull - a constant pointer value that points to null.
SizeOffsetType visitUndefValue(UndefValue &)
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
SizeOffsetType compute(Value *V)
Class for arbitrary precision integers.
std::pair< Value *, Value * > SizeOffsetEvalType
SizeOffsetEvalType visitIntToPtrInst(IntToPtrInst &)
Type * getMallocAllocatedType(const CallInst *CI, const TargetLibraryInfo *TLI)
getMallocAllocatedType - Returns the Type allocated by malloc call.
SizeOffsetEvalType visitPHINode(PHINode &PHI)
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 ...
SizeOffsetEvalType compute(Value *V)
SizeOffsetEvalType visitLoadInst(LoadInst &I)
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)
bool bothKnown(SizeOffsetType &SizeOffset)
bool knownOffset(SizeOffsetType &SizeOffset)
LLVM Value Representation.
SizeOffsetEvalType visitExtractElementInst(ExtractElementInst &I)
SizeOffsetType visitLoadInst(LoadInst &I)
SizeOffsetEvalType visitAllocaInst(AllocaInst &I)
bool bothKnown(SizeOffsetEvalType SizeOffset)
SizeOffsetType visitConstantPointerNull(ConstantPointerNull &)
SizeOffsetEvalType visitExtractValueInst(ExtractValueInst &I)
AllocaInst - an instruction to allocate memory on the stack.