15 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H
16 #define LLVM_ANALYSIS_MEMORYBUILTINS_H
25 #include "llvm/Support/DataTypes.h"
31 class TargetLibraryInfo;
45 bool LookThroughBitCast =
false);
49 bool isNoAliasFn(
const Value *V,
const TargetLibraryInfo *TLI,
50 bool LookThroughBitCast =
false);
55 bool LookThroughBitCast =
false);
60 bool LookThroughBitCast =
false);
64 bool isAllocLikeFn(
const Value *V,
const TargetLibraryInfo *TLI,
65 bool LookThroughBitCast =
false);
85 PointerType *
getMallocType(
const CallInst *CI,
const TargetLibraryInfo *TLI);
100 const TargetLibraryInfo *TLI,
101 bool LookThroughSExt =
false);
121 const CallInst *
isFreeCall(
const Value *
I,
const TargetLibraryInfo *TLI);
141 const TargetLibraryInfo *TLI,
bool RoundToAlign =
false,
150 const DataLayout &DL,
151 const TargetLibraryInfo *TLI,
159 :
public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
183 return SizeOffset.first.getBitWidth() > 1;
187 return SizeOffset.second.getBitWidth() > 1;
219 :
public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
222 typedef std::pair<WeakVH, WeakVH> WeakEvalType;
237 return std::make_pair(
nullptr,
nullptr);
247 return SizeOffset.first;
251 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...
static bool knownSize(const SizeOffsetType &SizeOffset)
This class represents a function call, abstracting a target machine's calling convention.
SizeOffsetType visitAllocaInst(AllocaInst &I)
An instruction for reading from memory.
SizeOffsetType visitArgument(Argument &A)
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.
SizeOffsetEvalType visitGEPOperator(GEPOperator &GEP)
SizeOffsetType visitExtractValueInst(ExtractValueInst &I)
SizeOffsetType visitGEPOperator(GEPOperator &GEP)
'undef' values are things that do not have specified contents.
bool knownSize(SizeOffsetEvalType SizeOffset)
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*.
bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, bool RoundToAlign=false, ObjSizeMode Mode=ObjSizeMode::Exact)
Compute the size of the object pointed by Ptr.
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)
ConstantInt * lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL, const TargetLibraryInfo *TLI, bool MustSucceed)
Try to turn a call to .objectsize into an integer value of the given Type.
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)
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.
SizeOffsetType visitPHINode(PHINode &)
A constant pointer value that points to null.
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)
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)
ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign=false, ObjSizeMode Mode=ObjSizeMode::Exact)
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.
SizeOffsetEvalType visitExtractElementInst(ExtractElementInst &I)
SizeOffsetType visitLoadInst(LoadInst &I)
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
SizeOffsetEvalType visitAllocaInst(AllocaInst &I)
bool bothKnown(SizeOffsetEvalType SizeOffset)
SizeOffsetType visitConstantPointerNull(ConstantPointerNull &)
SizeOffsetEvalType visitExtractValueInst(ExtractValueInst &I)
an instruction to allocate memory on the stack