35 return Base->getPointerAlignment(
DL) >= Alignment;
45 bool PtrCanBeFreed = Ptr->
canBeFreed() && !IgnoreFree;
47 bool IsDerefable =
false;
49 Ptr, {Attribute::Dereferenceable, Attribute::Alignment}, *SQ.
AC,
53 if (RK.
AttrKind == Attribute::Alignment) {
54 IsAligned |= RK.
ArgValue >= Alignment.value();
65 return IsAligned && IsDerefable;
75 assert(
V->getType()->isPointerTy() &&
"Base must be pointer");
108 IgnoreFree, Visited, MaxDepth);
113 if (BC->getSrcTy()->isPointerTy())
115 Size, SQ, IgnoreFree, Visited,
122 Size, SQ, IgnoreFree, Visited,
125 Size, SQ, IgnoreFree, Visited,
129 auto IsKnownDeref = [&]() {
130 bool CheckForNonNull, CheckForFreed;
131 if (!
Size.ule(
V->getPointerDereferenceableBytes(SQ.
DL, CheckForNonNull,
138 if (CheckForFreed && !IgnoreFree) {
144 DefI = &
II->getNormalDest()->front();
145 }
else if (!
I->isTerminator()) {
146 DefI =
I->getNextNode();
171 if (IsKnownDeref()) {
186 IgnoreFree, Visited, MaxDepth);
203 APInt KnownDerefBytes(
Size.getBitWidth(), ObjSize);
218 Alignment,
Size, SQ, IgnoreFree,
223 ASC->getOperand(0), Alignment,
Size, SQ, IgnoreFree, Visited, MaxDepth);
242 return ::isDereferenceableAndAlignedPointer(V, Alignment,
Size, SQ,
253 if (!Ty->isSized() || Ty->isScalableTy())
314 DL.getTypeStoreSize(LI->
getType()).getFixedValue());
318 if (L->isLoopInvariant(Ptr))
325 L, SE, DT, AC, Predicates);
336 if (!AddRec || AddRec->getLoop() != L || !AddRec->isAffine())
347 if (EltSize.
urem(Alignment.value()) != 0 ||
348 Step->getAPInt().
urem(Alignment.value()) != 0)
352 if (EltSize.
ugt(Step->getAPInt().abs()))
355 const SCEV *MaxBECount =
358 const SCEV *BECount = Predicates
365 auto &
DL = L->getHeader()->getDataLayout();
366 const auto &[AccessStart, AccessEnd] =
368 nullptr, &DT, AC, LoopGuards);
383 const SCEV *AccessSizeSCEV =
nullptr;
385 Base = NewBase->getValue();
386 AccessSize = std::move(MaxPtrDiff);
387 AccessSizeSCEV = PtrDiff;
389 if (MinAdd->getNumOperands() != 2)
401 if (
Offset->getAPInt().isNegative())
407 if (
Offset->getAPInt().urem(Alignment.value()) != 0)
410 bool Overflow =
false;
411 AccessSize = MaxPtrDiff.
uadd_ov(
Offset->getAPInt(), Overflow);
415 Base = NewBase->getValue();
419 Instruction *CtxI = &*L->getHeader()->getFirstNonPHIIt();
420 if (
BasicBlock *LoopPred = L->getLoopPredecessor()) {
422 CtxI = LoopPred->getTerminator();
426 Base, Alignment, SQ,
false,
431 const SCEV *AccessSizeExt =
433 const SCEV *DerefBytesExt =
446 return F.hasFnAttribute(Attribute::SanitizeThread) ||
447 F.hasFnAttribute(Attribute::SanitizeConcurrency) ||
449 F.hasFnAttribute(Attribute::SanitizeAddress) ||
450 F.hasFnAttribute(Attribute::SanitizeHWAddress);
471 if (
Size.getBitWidth() > 64)
484 V = V->stripPointerCasts();
491 if (!IgnoreFree &&
isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
495 const Value *AccessedPtr;
502 if (LI->isVolatile())
504 AccessedPtr = LI->getPointerOperand();
505 AccessedTy = LI->getType();
506 AccessedAlign = LI->getAlign();
509 if (
SI->isVolatile())
511 AccessedPtr =
SI->getPointerOperand();
512 AccessedTy =
SI->getValueOperand()->getType();
513 AccessedAlign =
SI->getAlign();
517 if (AccessedAlign < Alignment)
521 if (AccessedPtr == V &&
551 cl::desc(
"Use this to specify the default maximum number of instructions "
552 "to scan backward from a given instruction, when searching for "
553 "available loaded value"));
557 unsigned MaxInstsToScan,
559 unsigned *NumScanedInst) {
561 if (!
Load->isUnordered())
566 ScanBB, ScanFrom, MaxInstsToScan,
AA, IsLoad,
574 const Value *StorePtr,
577 APInt LoadOffset(
DL.getIndexTypeSizeInBits(LoadPtr->
getType()), 0);
578 APInt StoreOffset(
DL.getIndexTypeSizeInBits(StorePtr->
getType()), 0);
582 DL, LoadOffset,
false);
584 DL, StoreOffset,
false);
585 if (LoadBase != StoreBase)
590 LoadOffset + LoadAccessSize.toRaw());
592 StoreOffset + StoreAccessSize.toRaw());
605 Type *AtomicAccessTy =
607 Type *OtherAtomicAccessTy =
609 return DL.getTypeStoreSize(AtomicAccessTy) ==
610 DL.getTypeStoreSize(OtherAtomicAccessTy);
625 if (LI->isAtomic() < AtLeastAtomic)
633 LI->getProperties(),
DL) &&
647 if (
SI->isAtomic() < AtLeastAtomic)
650 Value *StorePtr =
SI->getPointerOperand()->stripPointerCasts();
657 Value *Val =
SI->getValueOperand();
659 SI->getProperties(),
DL))
666 TypeSize LoadSize =
DL.getTypeSizeInBits(AccessTy);
684 int64_t StoreOffset = 0, LoadOffset = 0;
685 const Value *StoreBase =
687 const Value *LoadBase =
689 if (StoreBase != LoadBase || LoadOffset < StoreOffset)
695 TypeSize LoadTypeSize =
DL.getTypeSizeInBits(AccessTy);
701 if ((Len->getValue() * 8).ult(LoadSize + (LoadOffset - StoreOffset) * 8))
705 : Val->getValue().trunc(LoadSize);
720 bool *IsLoadCSE,
unsigned *NumScanedInst) {
721 if (MaxInstsToScan == 0)
722 MaxInstsToScan = ~0U;
725 const Value *StrippedPtr =
Loc.Ptr->stripPointerCasts();
727 while (ScanFrom != ScanBB->
begin()) {
741 if (MaxInstsToScan-- == 0)
747 AccessProps,
DL, IsLoadCSE))
752 Value *StorePtr =
SI->getPointerOperand()->stripPointerCasts();
759 StrippedPtr != StorePtr)
768 Loc.Ptr, AccessTy,
SI->getPointerOperand(),
769 SI->getValueOperand()->getType(),
DL))
803 unsigned MaxInstsToScan) {
805 Value *StrippedPtr =
Load->getPointerOperand()->stripPointerCasts();
810 if (!
Load->isUnordered())
822 if (MaxInstsToScan-- == 0)
830 if (Inst.mayWriteToMemory())
850 unsigned ScanLimit) {
857 if (std::min(MemLocAlign,
SI->getAlign()).value() <
862 if (!LI || LI->getParent() !=
SI->getParent())
868 unsigned NumVisited = 0;
870 if (++NumVisited > ScanLimit ||
isModSet(
AA.getModRefInfo(
I, MemLoc)))
883 while (!Worklist.empty() && --Limit) {
884 auto *
User = Worklist.pop_back_val();
915 auto IsBasedOnConstantGlobal = [](
const Value *
V) {
917 return GV && GV->isConstant();
921 IsBasedOnConstantGlobal(To))
930 assert(U->getType() == Ty &&
"values must have matching types");
932 if (!Ty->isPtrOrPtrVectorTy())
942 bool HasNonAddressBits =
943 DL.getAddressSizeInBits(Ty) !=
DL.getPointerTypeSizeInBits(Ty);
969 NonDereferenceableAndAlignedLoads.
push_back(LI);
970 }
else if (
I.mayReadFromMemory() ||
I.mayWriteToMemory() ||
988 if (!
GEP ||
GEP->getSourceElementType()->isScalableTy())
991 Value *VarIndex =
nullptr;
992 for (
Value *Index :
GEP->indices()) {
997 if (Expr.
Index || VarIndex)
1010 ?
GEP->getNoWrapFlags()
1016 Value *UnscaledIndex =
nullptr;
1018 bool FoundIndexScale =
true;
1025 FoundIndexScale =
false;
1028 if (FoundIndexScale) {
1031 if (!BO->hasNoSignedWrap())
1033 if (!BO->hasNoUnsignedWrap())
1036 VarIndex = UnscaledIndex;
1041 GTI != GTE; ++GTI) {
1042 Value *Index = GTI.getOperand();
1044 if (ConstOffset->isZero())
1046 if (
StructType *STy = GTI.getStructTypeOrNull()) {
1047 unsigned ElementIdx = ConstOffset->getZExtValue();
1061 assert(Expr.
Index ==
nullptr &&
"Shouldn't have index yet");
1062 Expr.
Index = VarIndex;
1075 return std::nullopt;
1081 if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
1082 return std::nullopt;
1087 TypeSize EltSize =
DL.getTypeStoreSize(EltTy);
1089 return std::nullopt;
1092 if (!Expr.Index || Expr.BasePtr != GV || Expr.Offset.getBitWidth() > 64)
1093 return std::nullopt;
1098 const APInt &Stride = Expr.Scale;
1099 const APInt &ConstOffset = Expr.Offset;
1102 if (!ConstOffset.
ult(Stride))
1103 return std::nullopt;
1107 return std::nullopt;
1116 bool StrideIsValid =
1117 Expr.Flags.hasNoUnsignedWrap() ||
1118 (Expr.Flags.hasNoUnsignedSignedWrap() ? !Stride.
isNegative()
1121 return std::nullopt;
1123 uint64_t ArrayElementCount =
1127 return ConstGlobalLoad(
DL, Expr, ArrayElementCount, GV, EltTy);
1131 assert(Idx < ElementCount);
1149 Value *Idx = Expr.Index;
1150 unsigned Shift = Expr.Scale.countr_zero();
1151 if (Expr.Flags.hasNoUnsignedWrap() || Expr.Flags.hasNoUnsignedSignedWrap() ||
1154 unsigned BitWidth = Expr.Scale.getBitWidth();
1156 return Builder.CreateAnd(Idx, ConstantInt::get(Idx->getType(), Mask));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
@ Available
We know the block is fully available. This is a fixpoint.
static bool AreEquivalentAddressValues(const Value *A, const Value *B)
Test if A and B will obviously have the same value.
static bool isPointerUseReplaceable(const Use &U, bool HasNonAddressBits)
static bool isPointerAlwaysReplaceable(const Value *From, const Value *To, const DataLayout &DL)
static bool isDereferenceableAndAlignedPointerViaAssumption(const Value *Ptr, Align Alignment, const SimplifyQuery &SQ, bool IgnoreFree, function_ref< bool(const RetainedKnowledge &RK)> CheckSize)
static bool areNonOverlapSameBaseLoadAndStore(const Value *LoadPtr, Type *LoadTy, const Value *StorePtr, Type *StoreTy, const DataLayout &DL)
static bool hasCompatibleAtomicAccessSize(Type *AccessTy, const LoadStoreInstProperties &AccessProps, Type *OtherAccessTy, const LoadStoreInstProperties &OtherProps, const DataLayout &DL)
static Value * getAvailableLoadStore(Instruction *Inst, const Value *Ptr, Type *AccessTy, const LoadStoreInstProperties &AccessProps, const DataLayout &DL, bool *IsLoadCSE)
static bool suppressSpeculativeLoadForSanitizers(const Instruction &CtxI)
This file provides utility analysis objects describing memory locations.
uint64_t IntrinsicInst * II
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
LLVM_ABI APInt urem(const APInt &RHS) const
Unsigned remainder operation.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool isNegative() const
Determine sign of this APInt.
LLVM_ABI APInt uadd_ov(const APInt &RHS, bool &Overflow) const
static LLVM_ABI APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
bool getBoolValue() const
Convert APInt to a boolean value.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
@ MustAlias
The two locations precisely alias each other.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
InstListType::iterator iterator
Instruction iterators...
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
static LLVM_ABI bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.
@ ICMP_ULE
unsigned less or equal
LLVM_ABI Value * buildCanonicalIndex(IRBuilderBase &Builder) const
Build the canonicalized index that will index the global without wrapping.
static LLVM_ABI std::optional< ConstGlobalLoad > fromLoadInst(LoadInst *LI)
Analyze a load instruction to a linear expression that loads from a constant global.
LLVM_ABI Constant * getElementAt(uint64_t Idx) const
Get the element of the global that the load instruction reads for the given canonical index.
This is the shared class of boolean and integer constants.
This class represents a range of values.
LLVM_ABI bool isEmptySet() const
Return true if this set contains no members.
LLVM_ABI ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
LLVM_ABI unsigned getIndexTypeSizeInBits(Type *Ty) const
The size in bits of the index used in GEP calculation for this type.
LLVM_ABI unsigned getPointerTypeSizeInBits(Type *) const
The pointer representation size in bits for this type.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Represents calls to the gc.relocate intrinsic.
GEPNoWrapFlags withoutNoUnsignedSignedWrap() const
GEPNoWrapFlags intersectForOffsetAdd(GEPNoWrapFlags Other) const
Given (gep (gep p, x), y), determine the nowrap flags for (gep p, x+y).
GEPNoWrapFlags withoutNoUnsignedWrap() const
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Common base class shared among various IRBuilders.
LLVM_ABI bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
An instruction for reading from memory.
Value * getPointerOperand()
bool isVolatile() const
Return true if this is a load from a volatile memory location.
Align getAlign() const
Return the alignment of the access that is being performed.
static LocationSize precise(uint64_t Value)
TypeSize getValue() const
Represents a single loop in the control flow graph.
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
LocationSize Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
This class represents an analyzed expression in the program.
Type * getType() const
Return the LLVM type of this SCEV expression.
static LoopGuards collectOnDemand(const Loop *L, ScalarEvolution &SE)
Return loop guards for loop L, which are collected on first use.
The main scalar evolution driver.
LLVM_ABI Type * getWiderType(Type *Ty1, Type *Ty2) const
LLVM_ABI const SCEV * getBackedgeTakenCount(const Loop *L, ExitCountKind Kind=Exact)
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCould...
LLVM_ABI const SCEV * getMinusSCEV(SCEVUse LHS, SCEVUse RHS, SCEVFlags Flags=SCEV::FlagNone, unsigned Depth=0)
Return LHS-RHS.
LLVM_ABI const SCEV * getConstant(ConstantInt *V)
LLVM_ABI const SCEV * getPredicatedBackedgeTakenCount(const Loop *L, SmallVectorImpl< const SCEVPredicate * > &Predicates)
Similar to getBackedgeTakenCount, except it will add a set of SCEV predicates to Predicates that are ...
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
LLVM_ABI SCEVUse getAddExpr(SmallVectorImpl< SCEVUse > &Ops, SCEVFlagsPair Flags={}, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
LLVM_ABI const SCEV * getNoopOrZeroExtend(const SCEV *V, Type *Ty)
Return a SCEV corresponding to a conversion of the input value to the specified type.
APInt getUnsignedRangeMax(const SCEV *S)
Determine the max of the unsigned range for a particular SCEV.
LLVM_ABI const SCEV * applyLoopGuards(const SCEV *Expr, const Loop *L)
Try to apply information from loop guards for L to Expr.
LLVM_ABI bool isKnownPredicate(CmpPredicate Pred, SCEVUse LHS, SCEVUse RHS, unsigned Depth=0)
Test if the given expression is known to satisfy the condition described by Pred, LHS,...
LLVM_ABI const SCEV * getPredicatedSymbolicMaxBackedgeTakenCount(const Loop *L, SmallVectorImpl< const SCEVPredicate * > &Predicates)
Similar to getSymbolicMaxBackedgeTakenCount, except it will add a set of SCEV predicates to Predicate...
const SCEV * getSymbolicMaxBackedgeTakenCount(const Loop *L)
When successful, this returns a SCEV that is greater than or equal to (i.e.
This class represents the LLVM 'select' instruction.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
TypeSize getElementOffset(unsigned Idx) const
Class to represent struct types.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
LLVM_ABI bool canBeFreed() const
Return true if the memory object referred to by V can by freed in the scope for which the SSA value d...
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
constexpr ScalarTy getFixedValue() const
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
self_iterator getIterator()
Abstract Attribute helper functions.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
auto m_Value()
Match an arbitrary value and ignore it.
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI RetainedKnowledge getKnowledgeForValue(const Value *V, ArrayRef< Attribute::AttrKind > AttrKinds, AssumptionCache &AC, function_ref< bool(RetainedKnowledge, Instruction *, const CallBase::BundleOpInfo *)> Filter=[](auto...) { return true;})
Return a valid Knowledge associated to the Value V if its Attribute kind is in AttrKinds and it match...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
@ Load
The value being inserted comes from a load (InsertElement only).
LLVM_ABI const Value * getArgumentAliasingToReturnedPointer(const CallBase *Call, bool MustPreserveOffset, bool MustPreserveProvenance=false)
This function returns call pointer argument that is considered the same by aliasing rules.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI bool isStorePreservingMemoryLocation(const StoreInst *SI, const MemoryLocation &MemLoc, Align MemLocAlign, BatchAAResults &AA, unsigned ScanLimit)
Check whether SI, which may alias MemLoc, can be safely skipped.
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
LLVM_ABI bool mustSuppressSpeculation(const LoadInst &LI)
Return true if speculation of the given load must be suppressed to avoid ordering or interfering with...
gep_type_iterator gep_type_end(const User *GEP)
LLVM_ABI Value * FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan=DefMaxInstsToScan, BatchAAResults *AA=nullptr, bool *IsLoadCSE=nullptr, unsigned *NumScanedInst=nullptr)
Scan backwards to see if we have the value of the given load available locally within a small number ...
LLVM_ABI bool isValidAssumeForContext(const Instruction *I, const Instruction *CtxI, const DominatorTree *DT=nullptr, bool AllowEphemerals=false)
Return true if it is valid to use the assumptions provided by an assume intrinsic,...
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI 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.
LLVM_ABI bool canReplacePointersInUseIfEqual(const Use &U, const Value *To, const DataLayout &DL)
LLVM_ABI bool canReplacePointersIfEqual(const Value *From, const Value *To, const DataLayout &DL)
Returns true if a pointer value From can be replaced with another pointer value \To if they are deeme...
bool isModSet(const ModRefInfo MRI)
LLVM_ABI LinearExpression decomposeLinearExpression(const DataLayout &DL, Value *Ptr)
Decompose a pointer into a linear expression.
generic_gep_type_iterator<> gep_type_iterator
LLVM_ABI Constant * ConstantFoldLoadFromConst(Constant *C, Type *Ty, const APInt &Offset, const DataLayout &DL)
Extract value of C at the given Offset reinterpreted as Ty.
LLVM_ABI const Value * getUnderlyingObjectAggressive(const Value *V, bool MustPreserveProvenance=false)
Like getUnderlyingObject(), but will try harder to find a single underlying object.
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth, bool MustPreserveProvenance=false)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
LLVM_ABI cl::opt< unsigned > DefMaxInstsToScan
The default number of maximum instructions to scan in the block, used by FindAvailableLoadedValue().
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI bool isKnownNonZero(const Value *V, const SimplifyQuery &Q, unsigned Depth=0)
Return true if the given value is known to be non-zero when defined.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
LLVM_ABI bool isSafeToLoadUnconditionally(Value *V, Align Alignment, const APInt &Size, const SimplifyQuery &SQ, bool IgnoreFree=false)
Return true if we know that executing a load from this value cannot trap.
LLVM_ABI bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, Align Alignment, const SimplifyQuery &Q, bool IgnoreFree=false)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested.
LLVM_ABI bool willNotFreeBetween(const Instruction *Assume, const Instruction *CtxI, const DominatorTree *DT=nullptr)
Returns true, if no instruction between Assume and CtxI may free (including through synchronization).
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isReadOnlyLoop(Loop *L, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, SmallVectorImpl< LoadInst * > &NonDereferenceableAndAlignedLoads, SmallVectorImpl< const SCEVPredicate * > *Predicates=nullptr)
Returns true if the loop contains read-only memory accesses and doesn't throw.
gep_type_iterator gep_type_begin(const User *GEP)
LLVM_ABI bool isDereferenceablePointer(const Value *V, Type *Ty, const SimplifyQuery &Q, bool IgnoreFree=false)
Equivalent to isDereferenceableAndAlignedPointer with an alignment of 1.
LLVM_ABI Value * findAvailablePtrLoadStore(const MemoryLocation &Loc, Type *AccessTy, const LoadStoreInstProperties &AccessProps, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan, BatchAAResults *AA, bool *IsLoadCSE, unsigned *NumScanedInst)
Scan backwards to see if we have the value of the given pointer available locally within a small numb...
LLVM_ABI bool isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L, ScalarEvolution &SE, DominatorTree &DT, AssumptionCache *AC=nullptr, SmallVectorImpl< const SCEVPredicate * > *Predicates=nullptr)
Return true if we can prove that the given load (which is assumed to be within the specified loop) wo...
LLVM_ABI std::pair< const SCEV *, const SCEV * > getStartAndEndForAccess(const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy, const SCEV *BTC, const SCEV *MaxBTC, ScalarEvolution *SE, DenseMap< std::pair< const SCEV *, const SCEV * >, std::pair< const SCEV *, const SCEV * > > *PointerBounds, DominatorTree *DT, AssumptionCache *AC, ScalarEvolution::LoopGuards &LoopGuards)
Calculate Start and End points of memory access using exact backedge taken count BTC if computable or...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Linear expression BasePtr + Index * Scale + Offset.
A structure representing the properties of a load or store instruction.
Various options to control the behavior of getObjectSize.
bool NullIsUnknownSize
If this is true, null pointers in address space 0 will be treated as though they can't be evaluated.
bool RoundToAlign
Whether to round the result up to the alignment of allocas, byval arguments, and global variables.
Represent one information held inside an operand bundle of an llvm.assume.
Attribute::AttrKind AttrKind
const TargetLibraryInfo * TLI