15 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H
16 #define LLVM_ANALYSIS_MEMORYBUILTINS_H
23 #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);
88 const CallInst *
isArrayMalloc(
const Value *
I,
const DataLayout *DL,
89 const TargetLibraryInfo *TLI);
96 PointerType *
getMallocType(
const CallInst *CI,
const TargetLibraryInfo *TLI);
111 const TargetLibraryInfo *TLI,
112 bool LookThroughSExt =
false);
133 const CallInst *
isFreeCall(
const Value *
I,
const TargetLibraryInfo *TLI);
150 bool getObjectSize(
const Value *Ptr, uint64_t &Size,
const DataLayout *DL,
151 const TargetLibraryInfo *TLI,
bool RoundToAlign =
false);
160 :
public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
182 return SizeOffset.first.getBitWidth() > 1;
186 return SizeOffset.second.getBitWidth() > 1;
216 :
public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
219 typedef std::pair<WeakVH, WeakVH> WeakEvalType;
244 return SizeOffset.first;
248 return SizeOffset.second;
COFF::RelocationTypeX86 Type
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...
ObjectSizeOffsetVisitor(const DataLayout *DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign=false)
LLVM Argument representation.
Base class for instruction visitors.
const CallInst * extractCallocCall(const Value *I, const TargetLibraryInfo *TLI)
SizeOffsetType visitAllocaInst(AllocaInst &I)
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()
SizeOffsetEvalType visitGEPOperator(GEPOperator &GEP)
SizeOffsetType visitExtractValueInst(ExtractValueInst &I)
SizeOffsetType visitGEPOperator(GEPOperator &GEP)
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 &)
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*. May create code to compute the resu...
std::pair< APInt, APInt > SizeOffsetType
SizeOffsetType visitInstruction(Instruction &I)
SizeOffsetType visitGlobalVariable(GlobalVariable &GV)
SizeOffsetEvalType visitSelectInst(SelectInst &I)
const CallInst * extractMallocCall(const Value *I, const TargetLibraryInfo *TLI)
Integer representation type.
This class represents a cast from an integer to a pointer.
ObjectSizeOffsetEvaluator(const DataLayout *DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign=false)
SizeOffsetType visitCallSite(CallSite CS)
PointerType * getMallocType(const CallInst *CI, const TargetLibraryInfo *TLI)
SizeOffsetType visitSelectInst(SelectInst &I)
SizeOffsetType visitExtractElementInst(ExtractElementInst &I)
SizeOffsetType visitGlobalAlias(GlobalAlias &GA)
SizeOffsetEvalType visitInstruction(Instruction &I)
Evaluate the size and offset of an object pointed to by a Value* statically. Fails if size or offset ...
SizeOffsetType visitPHINode(PHINode &)
SizeOffsetType visitUndefValue(UndefValue &)
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)
const CallInst * isArrayMalloc(const Value *I, const DataLayout *DL, const TargetLibraryInfo *TLI)
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 ...
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Value * getMallocArraySize(CallInst *CI, const DataLayout *DL, const TargetLibraryInfo *TLI, bool LookThroughSExt=false)
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)
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. Returns true and the object size in Size if successful...
SizeOffsetType visitLoadInst(LoadInst &I)
SizeOffsetEvalType visitAllocaInst(AllocaInst &I)
bool bothKnown(SizeOffsetEvalType SizeOffset)
SizeOffsetType visitConstantPointerNull(ConstantPointerNull &)
SizeOffsetEvalType visitExtractValueInst(ExtractValueInst &I)