LLVM  4.0.0
Namespaces | Macros | Functions | Variables
LazyValueInfo.cpp File Reference
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
#include <stack>
Include dependency graph for LazyValueInfo.cpp:

Go to the source code of this file.

Namespaces

 llvm
 Compute iterated dominance frontiers using a linear time algorithm.
 

Macros

#define DEBUG_TYPE   "lazy-value-info"
 

Functions

 INITIALIZE_PASS_BEGIN (LazyValueInfoWrapperPass,"lazy-value-info","Lazy Value Information Analysis", false, true) INITIALIZE_PASS_END(LazyValueInfoWrapperPass
 
FunctionPassllvm::createLazyValueInfoPass ()
 createLazyValueInfoPass - This creates an instance of the LazyValueInfo pass. More...
 
raw_ostreamllvm::operator<< (raw_ostream &OS, const LVILatticeVal &Val) LLVM_ATTRIBUTE_USED
 
static bool hasSingleValue (const LVILatticeVal &Val)
 Returns true if this lattice value represents at most one possible value. More...
 
static LVILatticeVal intersect (LVILatticeVal A, LVILatticeVal B)
 Combine two sets of facts about the same value into a single set of facts. More...
 
static LVILatticeVal getFromRangeMetadata (Instruction *BBI)
 
static bool InstructionDereferencesPointer (Instruction *I, Value *Ptr)
 
static bool isObjectDereferencedInBlock (Value *Val, BasicBlock *BB)
 Return true if the allocation associated with Val is ever dereferenced within the given basic block. More...
 
static LVILatticeVal getValueFromCondition (Value *Val, Value *Cond, bool isTrueDest=true)
 
static LVILatticeVal getValueFromICmpCondition (Value *Val, ICmpInst *ICI, bool isTrueDest)
 
static LVILatticeVal getValueFromCondition (Value *Val, Value *Cond, bool isTrueDest, DenseMap< Value *, LVILatticeVal > &Visited)
 
static LVILatticeVal getValueFromConditionImpl (Value *Val, Value *Cond, bool isTrueDest, DenseMap< Value *, LVILatticeVal > &Visited)
 
static bool getEdgeValueLocal (Value *Val, BasicBlock *BBFrom, BasicBlock *BBTo, LVILatticeVal &Result)
 Compute the value of Val on the edge BBFrom -> BBTo. More...
 
static LazyValueInfoImpl & getImpl (void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
 This lazily constructs the LazyValueInfoImpl. More...
 
static bool isKnownNonConstant (Value *V)
 Returns true if we can statically tell that this value will never be a "useful" constant. More...
 
static LazyValueInfo::Tristate getPredicateResult (unsigned Pred, Constant *C, LVILatticeVal &Result, const DataLayout &DL, TargetLibraryInfo *TLI)
 

Variables

lazy value info
 
lazy value Lazy Value Information Analysis
 
lazy value Lazy Value Information false
 

Macro Definition Documentation

#define DEBUG_TYPE   "lazy-value-info"

Definition at line 40 of file LazyValueInfo.cpp.

Function Documentation

static bool getEdgeValueLocal ( Value Val,
BasicBlock BBFrom,
BasicBlock BBTo,
LVILatticeVal &  Result 
)
static

Compute the value of Val on the edge BBFrom -> BBTo.

Returns false if Val is not constrained on the edge. Result is unspecified if return value is false.

Definition at line 1297 of file LazyValueInfo.cpp.

References assert(), llvm::ConstantRange::difference(), llvm::ConstantInt::get(), llvm::SelectInst::getCondition(), llvm::Value::getContext(), llvm::Type::getInt1Ty(), llvm::Type::getIntegerBitWidth(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), getValueFromCondition(), i, and llvm::ConstantRange::unionWith().

static LVILatticeVal getFromRangeMetadata ( Instruction BBI)
static
static LazyValueInfoImpl& getImpl ( void *&  PImpl,
AssumptionCache AC,
const DataLayout DL,
DominatorTree DT = nullptr 
)
static
static LazyValueInfo::Tristate getPredicateResult ( unsigned  Pred,
Constant C,
LVILatticeVal &  Result,
const DataLayout DL,
TargetLibraryInfo TLI 
)
static
LVILatticeVal getValueFromCondition ( Value Val,
Value Cond,
bool  isTrueDest = true 
)
static

Definition at line 1288 of file LazyValueInfo.cpp.

References assert().

Referenced by getEdgeValueLocal(), and getValueFromConditionImpl().

static LVILatticeVal getValueFromCondition ( Value Val,
Value Cond,
bool  isTrueDest,
DenseMap< Value *, LVILatticeVal > &  Visited 
)
static
static LVILatticeVal getValueFromConditionImpl ( Value Val,
Value Cond,
bool  isTrueDest,
DenseMap< Value *, LVILatticeVal > &  Visited 
)
static
static LVILatticeVal getValueFromICmpCondition ( Value Val,
ICmpInst ICI,
bool  isTrueDest 
)
static
static bool hasSingleValue ( const LVILatticeVal &  Val)
static

Returns true if this lattice value represents at most one possible value.

This is as precise as any lattice value can get while still representing reachable code.

Definition at line 274 of file LazyValueInfo.cpp.

Referenced by intersect().

INITIALIZE_PASS_BEGIN ( LazyValueInfoWrapperPass  ,
"lazy-value-info ,
"Lazy Value Information Analysis ,
false  ,
true   
)
static bool InstructionDereferencesPointer ( Instruction I,
Value Ptr 
)
static
static LVILatticeVal intersect ( LVILatticeVal  A,
LVILatticeVal  B 
)
static

Combine two sets of facts about the same value into a single set of facts.

Note that this method is not suitable for merging facts along different paths in a CFG; that's what the mergeIn function is for. This is for merging facts gathered about the same value at the same location through two independent means. Notes:

  • This method does not promise to return the most precise possible lattice value implied by A and B. It is allowed to return any lattice element which is at least as strong as either A or B (unless our facts conflict, see below).
  • Due to unreachable code, the intersection of two lattice values could be contradictory. If this happens, we return some valid lattice value so as not confuse the rest of LVI. Ideally, we'd always return Undefined, but we do not make this guarantee. TODO: This would be a useful enhancement.

Definition at line 299 of file LazyValueInfo.cpp.

References A, and hasSingleValue().

Referenced by getValueFromConditionImpl().

static bool isKnownNonConstant ( Value V)
static

Returns true if we can statically tell that this value will never be a "useful" constant.

In practice, this means we've got something like an alloca or a malloc call for which a comparison against a constant can only be guarding dead code. Note that we are potentially giving up some precision in dead code (a constant result) in favour of avoiding a expensive search for a easily answered common query.

Definition at line 1522 of file LazyValueInfo.cpp.

References llvm::Value::stripPointerCasts().

Referenced by llvm::LazyValueInfo::getConstant().

static bool isObjectDereferencedInBlock ( Value Val,
BasicBlock BB 
)
static

Return true if the allocation associated with Val is ever dereferenced within the given basic block.

This establishes the fact Val is not null, but does not imply that the memory at Val is dereferenceable. (Val may point off the end of the dereferenceable part of the object.)

Definition at line 806 of file LazyValueInfo.cpp.

References assert(), llvm::Module::getDataLayout(), llvm::BasicBlock::getModule(), llvm::Value::getType(), llvm::GetUnderlyingObject(), InstructionDereferencesPointer(), and llvm::Type::isPointerTy().

Variable Documentation

lazy value Lazy Value Information Analysis

Definition at line 47 of file LazyValueInfo.cpp.

lazy value Lazy Value Information false

Definition at line 47 of file LazyValueInfo.cpp.

lazy value info