15 #ifndef LLVM_ANALYSIS_VALUETRACKING_H
16 #define LLVM_ANALYSIS_VALUETRACKING_H
20 #include "llvm/Support/DataTypes.h"
29 class AssumptionCache;
31 class TargetLibraryInfo;
43 const DataLayout &DL,
unsigned Depth = 0,
44 AssumptionCache *AC =
nullptr,
45 const Instruction *CxtI =
nullptr,
46 const DominatorTree *DT =
nullptr);
53 AssumptionCache *AC =
nullptr,
54 const Instruction *CxtI =
nullptr,
55 const DominatorTree *DT =
nullptr);
60 const DataLayout &DL,
unsigned Depth = 0,
61 AssumptionCache *AC =
nullptr,
62 const Instruction *CxtI =
nullptr,
63 const DominatorTree *DT =
nullptr);
71 bool OrZero =
false,
unsigned Depth = 0,
72 AssumptionCache *AC =
nullptr,
73 const Instruction *CxtI =
nullptr,
74 const DominatorTree *DT =
nullptr);
80 bool isKnownNonZero(Value *V,
const DataLayout &DL,
unsigned Depth = 0,
81 AssumptionCache *AC =
nullptr,
82 const Instruction *CxtI =
nullptr,
83 const DominatorTree *DT =
nullptr);
95 unsigned Depth = 0, AssumptionCache *AC =
nullptr,
96 const Instruction *CxtI =
nullptr,
97 const DominatorTree *DT =
nullptr);
108 unsigned Depth = 0, AssumptionCache *AC =
nullptr,
109 const Instruction *CxtI =
nullptr,
110 const DominatorTree *DT =
nullptr);
118 bool LookThroughSExt =
false,
145 ArrayRef<unsigned> idx_range,
146 Instruction *InsertBefore =
nullptr);
152 const DataLayout &DL);
153 static inline const Value *
167 uint64_t Offset = 0,
bool TrimAtNul =
true);
179 unsigned MaxLookup = 6);
182 unsigned MaxLookup = 6) {
215 const DataLayout &DL, LoopInfo *LI =
nullptr,
216 unsigned MaxLookup = 6);
227 const Instruction *CtxI =
nullptr,
228 const DominatorTree *DT =
nullptr,
229 const TargetLibraryInfo *TLI =
nullptr);
256 const Instruction *CtxI =
nullptr,
257 const DominatorTree *DT =
nullptr,
258 const TargetLibraryInfo *TLI =
nullptr);
263 bool isKnownNonNull(
const Value *V,
const TargetLibraryInfo *TLI =
nullptr);
270 const Instruction *CtxI =
nullptr,
271 const DominatorTree *DT =
nullptr,
272 const TargetLibraryInfo *TLI =
nullptr);
278 const DominatorTree *DT =
nullptr);
282 const DataLayout &DL,
284 const Instruction *CxtI,
285 const DominatorTree *DT);
287 const DataLayout &DL,
289 const Instruction *CxtI,
290 const DominatorTree *DT);
A parsed version of the target data layout string in and methods for querying it. ...
uint64_t GetStringLength(Value *V)
GetStringLength - If we can compute the length of the string pointed to by the specified pointer...
Value * isBytewiseValue(Value *V)
isBytewiseValue - If the specified value can be set by repeating the same byte in memory...
void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
bool haveNoCommonBitsSet(Value *LHS, Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Returns true if LHS and RHS have no common bits set.
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr)
Return true if it is valid to use the assumptions provided by an assume intrinsic, I, at the point in the control-flow identified by the context instruction, CxtI.
void GetUnderlyingObjects(Value *V, SmallVectorImpl< Value * > &Objects, const DataLayout &DL, LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to GetUnderlyingObject except that it can look through phi and select instruct...
void computeKnownBitsFromRangeMetadata(const MDNode &Ranges, APInt &KnownZero)
Compute known bits from the range metadata.
SelectPatternFlavor matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
bool isDereferenceablePointer(const Value *V, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
isDereferenceablePointer - Return true if this is always a dereferenceable pointer.
bool MaskedValueIsZero(Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
MaskedValueIsZero - Return true if 'V & Mask' is known to be zero.
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL)
GetPointerBaseWithConstantOffset - Analyze the specified pointer to see if it can be expressed as a b...
bool isKnownToBeAPowerOfTwo(Value *V, const DataLayout &DL, bool OrZero=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
isKnownToBeAPowerOfTwo - Return true if the given value is known to have exactly one bit set when def...
OverflowResult computeOverflowForUnsignedAdd(Value *LHS, Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
bool onlyUsedByLifetimeMarkers(const Value *V)
onlyUsedByLifetimeMarkers - Return true if the only users of this pointer are lifetime markers...
OverflowResult computeOverflowForUnsignedMul(Value *LHS, Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
ComputeSignBit - Determine whether the sign bit is known to be zero or one.
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
GetUnderlyingObject - This method strips off any GEP address adjustments and pointer casts from the s...
Value * FindInsertedValue(Value *V, ArrayRef< unsigned > idx_range, Instruction *InsertBefore=nullptr)
FindInsertedValue - Given an aggregrate and an sequence of indices, see if the scalar value indexed i...
SelectPatternFlavor
Specific patterns of select instructions we can match.
unsigned ComputeNumSignBits(Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
ComputeNumSignBits - Return the number of times the sign bit of the register is replicated into the o...
bool isKnownNonNullAt(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
isKnownNonNullAt - Return true if this pointer couldn't possibly be null.
bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI=nullptr)
isKnownNonNull - Return true if this pointer couldn't possibly be null by its definition.
bool isKnownNonZero(Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
isKnownNonZero - Return true if the given value is known to be non-zero when defined.
bool CannotBeOrderedLessThanZero(const Value *V, unsigned Depth=0)
CannotBeOrderedLessThanZero - Return true if we can prove that the specified FP value is either a NaN...
bool ComputeMultiple(Value *V, unsigned Base, Value *&Multiple, bool LookThroughSExt=false, unsigned Depth=0)
ComputeMultiple - This function computes the integer multiple of Base that equals V...
bool getConstantStringInfo(const Value *V, StringRef &Str, uint64_t Offset=0, bool TrimAtNul=true)
getConstantStringInfo - This function computes the length of a null-terminated C string pointed to by...
bool CannotBeNegativeZero(const Value *V, unsigned Depth=0)
CannotBeNegativeZero - Return true if we can prove that the specified FP value is never equal to -0...
LLVM Value Representation.
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
isSafeToSpeculativelyExecute - Return true if the instruction does not have any effects besides calcu...