LLVM  8.0.1
Classes | Namespaces | Enumerations | Functions
ValueTracking.h File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Intrinsics.h"
#include <cassert>
#include <cstdint>
Include dependency graph for ValueTracking.h:

Go to the source code of this file.

Classes

struct  llvm::ConstantDataArraySlice
 Represents offset+length into a ConstantDataArray. More...
 
struct  llvm::SelectPatternResult
 

Namespaces

 llvm
 This class represents lattice values for constants.
 

Enumerations

enum  llvm::OverflowResult { llvm::OverflowResult::AlwaysOverflows, llvm::OverflowResult::MayOverflow, llvm::OverflowResult::NeverOverflows }
 
enum  llvm::SelectPatternFlavor {
  llvm::SPF_UNKNOWN = 0, llvm::SPF_SMIN, llvm::SPF_UMIN, llvm::SPF_SMAX,
  llvm::SPF_UMAX, llvm::SPF_FMINNUM, llvm::SPF_FMAXNUM, llvm::SPF_ABS,
  llvm::SPF_NABS
}
 Specific patterns of select instructions we can match. More...
 
enum  llvm::SelectPatternNaNBehavior { llvm::SPNB_NA = 0, llvm::SPNB_RETURNS_NAN, llvm::SPNB_RETURNS_OTHER, llvm::SPNB_RETURNS_ANY }
 Behavior when a floating point min/max is given one NaN and one non-NaN as input. More...
 

Functions

void llvm::computeKnownBits (const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
 Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOne bit sets. More...
 
KnownBits llvm::computeKnownBits (const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
 Returns the known bits rather than passing by reference. More...
 
void llvm::computeKnownBitsFromRangeMetadata (const MDNode &Ranges, KnownBits &Known)
 Compute known bits from the range metadata. More...
 
bool llvm::haveNoCommonBitsSet (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return true if LHS and RHS have no common bits set. More...
 
bool llvm::isKnownToBeAPowerOfTwo (const Value *V, const DataLayout &DL, bool OrZero=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return true if the given value is known to have exactly one bit set when defined. More...
 
bool llvm::isOnlyUsedInZeroEqualityComparison (const Instruction *CxtI)
 
bool llvm::isKnownNonZero (const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return true if the given value is known to be non-zero when defined. More...
 
bool llvm::isKnownNegation (const Value *X, const Value *Y, bool NeedNSW=false)
 Return true if the two given values are negation. More...
 
bool llvm::isKnownNonNegative (const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Returns true if the give value is known to be non-negative. More...
 
bool llvm::isKnownPositive (const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Returns true if the given value is known be positive (i.e. More...
 
bool llvm::isKnownNegative (const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Returns true if the given value is known be negative (i.e. More...
 
bool llvm::isKnownNonEqual (const Value *V1, const Value *V2, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return true if the given values are known to be non-equal when defined. More...
 
bool llvm::MaskedValueIsZero (const Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return true if 'V & Mask' is known to be zero. More...
 
unsigned llvm::ComputeNumSignBits (const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
 Return the number of times the sign bit of the register is replicated into the other bits. More...
 
bool llvm::ComputeMultiple (Value *V, unsigned Base, Value *&Multiple, bool LookThroughSExt=false, unsigned Depth=0)
 This function computes the integer multiple of Base that equals V. More...
 
Intrinsic::ID llvm::getIntrinsicForCallSite (ImmutableCallSite ICS, const TargetLibraryInfo *TLI)
 Map a call instruction to an intrinsic ID. More...
 
bool llvm::CannotBeNegativeZero (const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
 Return true if we can prove that the specified FP value is never equal to -0.0. More...
 
bool llvm::CannotBeOrderedLessThanZero (const Value *V, const TargetLibraryInfo *TLI)
 Return true if we can prove that the specified FP value is either NaN or never less than -0.0. More...
 
bool llvm::isKnownNeverNaN (const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
 Return true if the floating-point scalar value is not a NaN or if the floating-point vector value has no NaN elements. More...
 
bool llvm::SignBitMustBeZero (const Value *V, const TargetLibraryInfo *TLI)
 Return true if we can prove that the specified FP value's sign bit is 0. More...
 
Valuellvm::isBytewiseValue (Value *V)
 If the specified value can be set by repeating the same byte in memory, return the i8 value that it is represented with. More...
 
Valuellvm::FindInsertedValue (Value *V, ArrayRef< unsigned > idx_range, Instruction *InsertBefore=nullptr)
 Given an aggregrate and an sequence of indices, see if the scalar value indexed is already around as a register, for example if it were inserted directly into the aggregrate. More...
 
Valuellvm::GetPointerBaseWithConstantOffset (Value *Ptr, int64_t &Offset, const DataLayout &DL)
 Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset. More...
 
const Value * llvm::GetPointerBaseWithConstantOffset (const Value *Ptr, int64_t &Offset, const DataLayout &DL)
 
bool llvm::isGEPBasedOnPointerToString (const GEPOperator *GEP, unsigned CharSize=8)
 Returns true if the GEP is based on a pointer to a string (array of. More...
 
bool llvm::getConstantDataArrayInfo (const Value *V, ConstantDataArraySlice &Slice, unsigned ElementSize, uint64_t Offset=0)
 Returns true if the value V is a pointer into a ConstantDataArray. More...
 
bool llvm::getConstantStringInfo (const Value *V, StringRef &Str, uint64_t Offset=0, bool TrimAtNul=true)
 This function computes the length of a null-terminated C string pointed to by V. More...
 
uint64_t llvm::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'. More...
 
const Valuellvm::getArgumentAliasingToReturnedPointer (const CallBase *Call)
 This function returns call pointer argument that is considered the same by aliasing rules. More...
 
Value * llvm::getArgumentAliasingToReturnedPointer (CallBase *Call)
 
bool llvm::isIntrinsicReturningPointerAliasingArgumentWithoutCapturing (const CallBase *Call)
 
Valuellvm::GetUnderlyingObject (Value *V, const DataLayout &DL, unsigned MaxLookup=6)
 This method strips off any GEP address adjustments and pointer casts from the specified value, returning the original object being addressed. More...
 
const Value * llvm::GetUnderlyingObject (const Value *V, const DataLayout &DL, unsigned MaxLookup=6)
 
void llvm::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 instructions and return multiple objects. More...
 
bool llvm::getUnderlyingObjectsForCodeGen (const Value *V, SmallVectorImpl< Value *> &Objects, const DataLayout &DL)
 This is a wrapper around GetUnderlyingObjects and adds support for basic ptrtoint+arithmetic+inttoptr sequences. More...
 
bool llvm::onlyUsedByLifetimeMarkers (const Value *V)
 Return true if the only users of this pointer are lifetime markers. More...
 
bool llvm::isSafeToSpeculativelyExecute (const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
 Return true if the instruction does not have any effects besides calculating the result and does not have undefined behavior. More...
 
bool llvm::mayBeMemoryDependent (const Instruction &I)
 Returns true if the result or effects of the given instructions I depend on or influence global memory. More...
 
bool llvm::isAssumeLikeIntrinsic (const Instruction *I)
 Return true if it is an intrinsic that cannot be speculated but also cannot trap. More...
 
bool llvm::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. More...
 
OverflowResult llvm::computeOverflowForUnsignedMul (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT, bool UseInstrInfo=true)
 
OverflowResult llvm::computeOverflowForSignedMul (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT, bool UseInstrInfo=true)
 
OverflowResult llvm::computeOverflowForUnsignedAdd (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT, bool UseInstrInfo=true)
 
OverflowResult llvm::computeOverflowForSignedAdd (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
 
OverflowResult llvm::computeOverflowForSignedAdd (const AddOperator *Add, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
 This version also leverages the sign bit of Add if known. More...
 
OverflowResult llvm::computeOverflowForUnsignedSub (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
 
OverflowResult llvm::computeOverflowForSignedSub (const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
 
bool llvm::isOverflowIntrinsicNoWrap (const IntrinsicInst *II, const DominatorTree &DT)
 Returns true if the arithmetic part of the II 's result is used only along the paths control dependent on the computation not overflowing, II being an <op>.with.overflow intrinsic. More...
 
bool llvm::isGuaranteedToTransferExecutionToSuccessor (const Instruction *I)
 Return true if this function can prove that the instruction I will always transfer execution to one of its successors (including the next instruction that follows within a basic block). More...
 
bool llvm::isGuaranteedToTransferExecutionToSuccessor (const BasicBlock *BB)
 Returns true if this block does not contain a potential implicit exit. More...
 
bool llvm::isGuaranteedToExecuteForEveryIteration (const Instruction *I, const Loop *L)
 Return true if this function can prove that the instruction I is executed for every iteration of the loop L. More...
 
bool llvm::propagatesFullPoison (const Instruction *I)
 Return true if this function can prove that I is guaranteed to yield full-poison (all bits poison) if at least one of its operands are full-poison (all bits poison). More...
 
const Valuellvm::getGuaranteedNonFullPoisonOp (const Instruction *I)
 Return either nullptr or an operand of I such that I will trigger undefined behavior if I is executed and that operand has a full-poison value (all bits poison). More...
 
bool llvm::programUndefinedIfFullPoison (const Instruction *PoisonI)
 Return true if this function can prove that if PoisonI is executed and yields a full-poison value (all bits poison), then that will trigger undefined behavior. More...
 
SelectPatternResult llvm::matchSelectPattern (Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
 Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out parameter results if we successfully match. More...
 
SelectPatternResult llvm::matchSelectPattern (const Value *V, const Value *&LHS, const Value *&RHS, Instruction::CastOps *CastOp=nullptr)
 
CmpInst::Predicate llvm::getMinMaxPred (SelectPatternFlavor SPF, bool Ordered=false)
 Return the canonical comparison predicate for the specified minimum/maximum flavor. More...
 
SelectPatternFlavor llvm::getInverseMinMaxFlavor (SelectPatternFlavor SPF)
 Return the inverse minimum/maximum flavor of the specified flavor. More...
 
CmpInst::Predicate llvm::getInverseMinMaxPred (SelectPatternFlavor SPF)
 Return the canonical inverse comparison predicate for the specified minimum/maximum flavor. More...
 
Optional< boolllvm::isImpliedCondition (const Value *LHS, const Value *RHS, const DataLayout &DL, bool LHSIsTrue=true, unsigned Depth=0)
 Return true if RHS is known to be implied true by LHS. More...
 
Optional< boolllvm::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 dominating conditions. More...