Go to the documentation of this file.
47 #include <type_traits>
52 #define DEBUG_TYPE "memory-builtins"
86 return "_ZnwmSt11align_val_t";
90 return "_ZnamSt11align_val_t";
92 return "??2@YAPAXI@Z";
94 return "??_U@YAPAXI@Z";
98 return "__kmpc_alloc_shared";
163 if (isa<IntrinsicInst>(V))
166 const auto *CB = dyn_cast<CallBase>(V);
170 IsNoBuiltin = CB->isNoBuiltin();
189 return P.first == TLIFn;
218 bool IsNoBuiltinCall;
220 if (!IsNoBuiltinCall)
228 bool IsNoBuiltinCall;
230 if (!IsNoBuiltinCall)
238 bool IsNoBuiltinCall;
246 if (!IsNoBuiltinCall)
261 Result.NumParams =
Callee->getNumOperands();
262 Result.FstParam =
Args.first;
263 Result.SndParam =
Args.second.getValueOr(-1);
265 Result.AlignParam = -1;
353 if (
I.getBitWidth() > IntTyBits &&
I.getActiveBits() > IntTyBits)
355 if (
I.getBitWidth() != IntTyBits)
356 I =
I.zextOrTrunc(IntTyBits);
373 const unsigned IntTyBits =
DL.getIndexTypeSizeInBits(CB->
getType());
388 APInt MaxSize =
Arg->getValue().zext(IntTyBits);
389 if (Size.ugt(MaxSize))
417 Size = Size.umul_ov(NumElems, Overflow);
485 return P.first == TLIFn;
496 if (
Callee ==
nullptr || IsNoBuiltin)
502 if (AllocData.hasValue())
505 if (FreeData.hasValue())
532 bool IsNoBuiltinCall;
534 if (
Callee ==
nullptr || IsNoBuiltinCall)
549 if (
Data.second.isNegative() ||
Data.first.ult(
Data.second))
550 return APInt(
Data.first.getBitWidth(), 0);
582 "ObjectSize must be a call to llvm.objectsize!");
584 bool MaxVal = cast<ConstantInt>(ObjectSize->
getArgOperand(1))->isZero();
599 auto *ResultType = cast<IntegerType>(ObjectSize->
getType());
600 bool StaticOnly = cast<ConstantInt>(ObjectSize->
getArgOperand(3))->isZero();
606 isUIntN(ResultType->getBitWidth(), Size))
616 Builder.SetInsertPoint(ObjectSize);
621 Builder.CreateSub(SizeOffsetPair.first, SizeOffsetPair.second);
623 Builder.CreateICmpULT(SizeOffsetPair.first, SizeOffsetPair.second);
624 ResultSize =
Builder.CreateZExtOrTrunc(ResultSize, ResultType);
629 if (!isa<Constant>(SizeOffsetPair.first) ||
630 !isa<Constant>(SizeOffsetPair.second))
645 "Number of arguments with unsolved size and offset");
647 "Number of load instructions with unsolved size and offset");
651 return APInt(IntTyBits,
alignTo(Size.getZExtValue(), Alignment));
672 APInt Offset(InitialIntTyBits, 0);
674 DL, Offset,
true,
true);
681 bool IndexTypeSizeChanged = InitialIntTyBits != IntTyBits;
682 if (!IndexTypeSizeChanged && Offset.isZero())
683 return computeImpl(V);
689 if (IndexTypeSizeChanged) {
690 if (
knownSize(SOT) && !::CheckedZextOrTrunc(SOT.first, InitialIntTyBits))
692 if (
knownOffset(SOT) && !::CheckedZextOrTrunc(SOT.second, InitialIntTyBits))
693 SOT.second =
APInt();
697 SOT.second.getBitWidth() > 1 ? SOT.second + Offset : SOT.second};
704 if (!SeenInsts.insert(
I).second)
709 if (
Argument *A = dyn_cast<Argument>(V))
720 LLVM_DEBUG(
dbgs() <<
"ObjectSizeOffsetVisitor::compute() unhandled value: "
725 bool ObjectSizeOffsetVisitor::CheckedZextOrTrunc(
APInt &
I) {
730 if (!
I.getAllocatedType()->isSized())
737 if (!
I.isArrayAllocation())
738 return std::make_pair(align(Size,
I.getAlign()), Zero);
740 Value *ArraySize =
I.getArraySize();
741 if (
const ConstantInt *
C = dyn_cast<ConstantInt>(ArraySize)) {
742 APInt NumElems =
C->getValue();
743 if (!CheckedZextOrTrunc(NumElems))
747 Size = Size.umul_ov(NumElems, Overflow);
748 return Overflow ? unknown()
749 : std::make_pair(align(Size,
I.getAlign()), Zero);
755 Type *MemoryTy = A.getPointeeInMemoryValueType();
757 if (!MemoryTy|| !MemoryTy->
isSized()) {
758 ++ObjectVisitorArgument;
763 return std::make_pair(align(Size, A.getParamAlign()), Zero);
767 auto Mapper = [](
const Value *V) {
return V; };
769 return std::make_pair(*Size, Zero);
784 return std::make_pair(Zero, Zero);
809 return std::make_pair(align(Size, GV.
getAlign()), Zero);
820 unsigned &ScannedInstCount) {
821 constexpr
unsigned MaxInstsToScan = 128;
823 auto Where = VisitedBlocks.
find(&
BB);
824 if (Where != VisitedBlocks.
end())
825 return Where->second;
827 auto Unknown = [
this, &
BB, &VisitedBlocks]() {
828 return VisitedBlocks[&
BB] = unknown();
831 return VisitedBlocks[&
BB] = SO;
837 if (
I.isDebugOrPseudoInst())
840 if (++ScannedInstCount > MaxInstsToScan)
843 if (!
I.mayWriteToMemory())
846 if (
auto *
SI = dyn_cast<StoreInst>(&
I)) {
848 Options.
AA->
alias(
SI->getPointerOperand(),
Load.getPointerOperand());
853 if (
SI->getValueOperand()->getType()->isPointerTy())
854 return Known(
compute(
SI->getValueOperand()));
862 if (
auto *CB = dyn_cast<CallBase>(&
I)) {
874 if (TLIFn != LibFunc_posix_memalign)
893 if (!Checked || !*Checked)
897 auto *
C = dyn_cast<ConstantInt>(Size);
901 return Known({
C->getValue(),
APInt(
C->getValue().getBitWidth(), 0)});
905 }
while (
From-- !=
BB.begin());
909 PredecessorSizeOffsets.push_back(findLoadSizeOffset(
911 VisitedBlocks, ScannedInstCount));
912 if (!
bothKnown(PredecessorSizeOffsets.back()))
916 if (PredecessorSizeOffsets.empty())
919 return Known(std::accumulate(PredecessorSizeOffsets.begin() + 1,
920 PredecessorSizeOffsets.end(),
921 PredecessorSizeOffsets.front(),
923 return combineSizeOffset(LHS, RHS);
934 unsigned ScannedInstCount = 0;
937 VisitedBlocks, ScannedInstCount);
962 return std::accumulate(IncomingValues.begin() + 1, IncomingValues.end(),
963 compute(*IncomingValues.begin()),
965 return combineSizeOffset(LHS, compute(VRHS));
970 return combineSizeOffset(
compute(
I.getTrueValue()),
975 return std::make_pair(Zero, Zero);
979 LLVM_DEBUG(
dbgs() <<
"ObjectSizeOffsetVisitor unknown instruction:" <<
I
1007 for (
const Value *SeenVal : SeenVals) {
1010 if (CacheIt != CacheMap.
end() &&
anyKnown(CacheIt->second))
1011 CacheMap.
erase(CacheIt);
1017 I->eraseFromParent();
1022 InsertedInstructions.clear();
1029 if (Visitor.bothKnown(Const))
1037 if (CacheIt != CacheMap.
end())
1038 return CacheIt->second;
1052 if (!SeenVals.
insert(V).second) {
1056 }
else if (
Instruction *
I = dyn_cast<Instruction>(V)) {
1058 }
else if (isa<Argument>(V) ||
1059 (isa<ConstantExpr>(V) &&
1060 cast<ConstantExpr>(V)->
getOpcode() == Instruction::IntToPtr) ||
1061 isa<GlobalAlias>(V) ||
1062 isa<GlobalVariable>(V)) {
1067 dbgs() <<
"ObjectSizeOffsetEvaluator::compute() unhandled value: " << *V
1078 if (!
I.getAllocatedType()->isSized())
1082 assert(
I.isArrayAllocation());
1089 "Expected zero constant to have pointer type");
1093 Size = Builder.
CreateMul(Size, ArraySize);
1094 return std::make_pair(Size, Zero);
1111 return std::make_pair(FirstArg, Zero);
1116 return std::make_pair(Size, Zero);
1136 Offset = Builder.
CreateAdd(PtrData.second, Offset);
1137 return std::make_pair(PtrData.first, Offset);
1155 CacheMap[&PHI] = std::make_pair(SizePHI, OffsetPHI);
1165 InsertedInstructions.erase(OffsetPHI);
1168 InsertedInstructions.erase(SizePHI);
1175 Value *Size = SizePHI, *Offset = OffsetPHI;
1180 InsertedInstructions.erase(SizePHI);
1186 InsertedInstructions.erase(OffsetPHI);
1188 return std::make_pair(Size, Offset);
1197 if (TrueSide == FalseSide)
1204 return std::make_pair(Size, Offset);
1208 LLVM_DEBUG(
dbgs() <<
"ObjectSizeOffsetEvaluator unknown instruction:" <<
I
Value * getArgOperandWithAttribute(Attribute::AttrKind Kind) const
If one of the arguments has the specified attribute, returns its operand value.
static SizeOffsetEvalType unknown()
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
std::pair< APInt, APInt > SizeOffsetType
This class represents an incoming formal argument to a Function.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
static Optional< AllocFnsTy > getAllocationSize(const Value *V, const TargetLibraryInfo *TLI)
SizeOffsetType visitGlobalAlias(GlobalAlias &GA)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
This is an optimization pass for GlobalISel generic memory operations.
static const std::pair< LibFunc, FreeFnsTy > FreeFnData[]
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
unsigned getIndexTypeSizeInBits(Type *Ty) const
Layout size of the index used in GEP calculation.
op_range incoming_values()
A parsed version of the target data layout string in and methods for querying it.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
InstListType::iterator iterator
Instruction iterators...
Optional< FreeFnsTy > getFreeFunctionDataForFunction(const Function *Callee, const LibFunc TLIFn)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SizeOffsetEvalType compute(Value *V)
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
SizeOffsetType visitExtractValueInst(ExtractValueInst &I)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
SizeOffsetEvalType visitSelectInst(SelectInst &I)
SizeOffsetEvalType visitGEPOperator(GEPOperator &GEP)
Constant * getInitialValueOfAllocation(const CallBase *Alloc, const TargetLibraryInfo *TLI, Type *Ty)
If this allocation function initializes memory to a fixed value, return said value in the requested t...
static bool isMallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates uninitialized memory (such ...
bool erase(const KeyT &Val)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Type * getIndexType(Type *PtrTy) const
Returns the type of a GEP index.
The instances of the Type class are immutable: once they are created, they are never changed.
bool NullIsUnknownSize
If this is true, null pointers in address space 0 will be treated as though they can't be evaluated.
const_iterator end(StringRef path)
Get end iterator over path.
SizeOffsetEvalType visitCallBase(CallBase &CB)
const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr) const
Accumulate the constant offset this value has compared to a base pointer.
The possible results of an alias query.
bool RoundToAlign
Whether to round the result up to the alignment of allocas, byval arguments, and global variables.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static Optional< AllocFnsTy > getAllocationData(const Value *V, AllocType AllocTy, const TargetLibraryInfo *TLI)
SizeOffsetEvalType visitLoadInst(LoadInst &I)
Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
LLVM Basic Block Representation.
constexpr bool hasValue() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
SizeOffsetEvalType visitIntToPtrInst(IntToPtrInst &)
bool isAllocationFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates or reallocates memory (eith...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
A constant pointer value that points to null.
This is the shared class of boolean and integer constants.
static bool bothKnown(const SizeOffsetType &SizeOffset)
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
(vector float) vec_cmpeq(*A, *B) C
SizeOffsetType visitIntToPtrInst(IntToPtrInst &)
ObjectSizeOffsetEvaluator(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts EvalOpts={})
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
@ Exact
Fail to evaluate an unknown condition.
static Optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
SizeOffsetType visitGlobalVariable(GlobalVariable &GV)
SizeOffsetType visitAllocaInst(AllocaInst &I)
SizeOffsetEvalType visitExtractElementInst(ExtractElementInst &I)
uint64_t getZExtValue() const
Get zero extended value.
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
STATISTIC(NumFunctions, "Total number of functions")
auto predecessors(MachineBasicBlock *BB)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Evaluate the size and offset of an object pointed to by a Value*.
FunctionType * getFunctionType()
SizeOffsetEvalType visitPHINode(PHINode &PHI)
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.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
bool isIntegerTy() const
True if this is an instance of IntegerType.
An efficient, type-erasing, non-owning reference to a callable.
This is an important base class in LLVM.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value,...
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
This is an important class for using LLVM in a threaded context.
SizeOffsetType visitUndefValue(UndefValue &)
static const Function * getCalledFunction(const Value *V, bool &IsNoBuiltin)
Type * getParamType(unsigned i) const
Parameter type accessors.
'undef' values are things that do not have specified contents.
Evaluate the size and offset of an object pointed to by a Value* statically.
Value * 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.
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
SizeOffsetType visitSelectInst(SelectInst &I)
void visit(Iterator Start, Iterator End)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates memory (either malloc,...
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
@ Min
Evaluate all branches of an unknown condition.
StandardInstrumentations SI(Debug, VerifyEach)
This class represents the LLVM 'select' instruction.
bool has(LibFunc F) const
Tests whether a library function is available.
print Print MemDeps of function
bool isVoidTy() const
Return true if this is 'void'.
Provides an 'InsertHelper' that calls a user-provided callback after performing the default insertion...
Class for arbitrary precision integers.
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
SizeOffsetEvalType visitAllocaInst(AllocaInst &I)
AAResults * AA
If set, used for more accurate evaluation.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
const Function * getFunction() const
Return the function this instruction belongs to.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
@ NoAlias
The two locations do not alias at all.
LLVMContext & getContext() const
All values hold a context through their type.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
@ MustAlias
The two locations precisely alias each other.
Various options to control the behavior of getObjectSize.
const Constant * getAliasee() const
static const std::pair< LibFunc, AllocFnsTy > AllocationFnData[]
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
An instruction for reading from memory.
@ Max
Same as Min, except we pick the maximum size of all of the branches.
SizeOffsetType visitLoadInst(LoadInst &I)
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
SizeOffsetType visitInstruction(Instruction &I)
amdgpu Simplify well known AMD library false FunctionCallee Callee
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....
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
uint64_t GetStringLength(const Value *V, unsigned CharSize=8)
If we can compute the length of the string pointed to by the specified pointer, return 'len+1'.
StringRef mangledNameForMallocFamily(const MallocFamily &Family)
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space.
TargetFolder - Create constants with target dependent folding.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
SizeOffsetType visitCallBase(CallBase &CB)
SizeOffsetType visitArgument(Argument &A)
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end iterator end()
Optional< StringRef > getAllocationFamily(const Value *I, const TargetLibraryInfo *TLI)
If a function is part of an allocation family (e.g.
Mode EvalMode
How we want to evaluate this object's size.
Value * getAllocAlignment(const CallBase *V, const TargetLibraryInfo *TLI)
Gets the alignment argument for an aligned_alloc-like function, using either built-in knowledge based...
std::pair< Value *, Value * > SizeOffsetEvalType
static bool knownOffset(const SizeOffsetType &SizeOffset)
Provides information about what library functions are available for the current target.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
static bool isCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates zero-filled memory (such as...
This class represents a cast from an integer to a pointer.
A wrapper class for inspecting calls to intrinsic functions.
SizeOffsetType compute(Value *V)
SizeOffsetType visitConstantPointerNull(ConstantPointerNull &)
static APInt getSizeWithOverflow(const SizeOffsetType &Data)
Optional< APInt > getAllocSize(const CallBase *CB, const TargetLibraryInfo *TLI, std::function< const Value *(const Value *)> Mapper)
Return the size of the requested allocation.
DenseMapIterator< const Value *, WeakEvalType, DenseMapInfo< const Value * >, llvm::detail::DenseMapPair< const Value *, WeakEvalType > > iterator
Optional< bool > isImpliedByDomCondition(const Value *Cond, const Instruction *ContextI, const DataLayout &DL)
Return the boolean condition value in the context of the given instruction if it is known based on do...
SizeOffsetEvalType visitExtractValueInst(ExtractValueInst &I)
bool isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that reallocates memory (e....
Value * getArgOperand(unsigned i) const
const BasicBlock * getParent() const
SizeOffsetEvalType visitInstruction(Instruction &I)
static bool knownSize(const SizeOffsetType &SizeOffset)
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
ScalarTy getKnownMinSize() const
static 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.
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
bool bothKnown(SizeOffsetEvalType SizeOffset)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Type * getValueType() const
This class represents a function call, abstracting a target machine's calling convention.
ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options={})
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
BlockVerifier::State From
PointerType * getType() const
Specialize the getType() method to always return an PointerType, which reduces the amount of casting ...
bool isAllocRemovable(const CallBase *V, const TargetLibraryInfo *TLI)
Return false if the allocation can have side effects on the program state we are required to preserve...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
an instruction to allocate memory on the stack
Value * getOperand(unsigned i) const
bool isLibFreeFunction(const Function *F, const LibFunc TLIFn)
isLibFreeFunction - Returns true if the function is a builtin free()
SizeOffsetType visitExtractElementInst(ExtractElementInst &I)
Type * getReturnType() const
LLVM Value Representation.
bool anyKnown(SizeOffsetEvalType SizeOffset)
bool isMallocOrCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates memory similar to malloc or...
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
SizeOffsetType visitPHINode(PHINode &)
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).
Class to represent function types.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static bool isAlignedAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that allocates uninitialized memory with a...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...