LLVM 20.0.0git
Classes | 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/InstructionSimplify.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/AssemblyAnnotationWriter.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/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Classes

class  llvm::LazyValueInfoImpl
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

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.
 
static bool hasSingleValue (const ValueLatticeElement &Val)
 Returns true if this lattice value represents at most one possible value.
 
static ValueLatticeElement getFromRangeMetadata (Instruction *BBI)
 
static void AddNonNullPointer (Value *Ptr, NonNullPointerSet &PtrSet)
 
static void AddNonNullPointersByInstruction (Instruction *I, NonNullPointerSet &PtrSet)
 
static bool matchICmpOperand (APInt &Offset, Value *LHS, Value *Val, ICmpInst::Predicate Pred)
 
static std::optional< ConstantRangegetRangeViaSLT (CmpInst::Predicate Pred, APInt RHS, function_ref< std::optional< ConstantRange >(const APInt &)> Fn)
 
static ValueLatticeElement getValueFromOverflowCondition (Value *Val, WithOverflowInst *WO, bool IsTrueDest)
 
static bool usesOperand (User *Usr, Value *Op)
 
static bool isOperationFoldable (User *Usr)
 
static ValueLatticeElement constantFoldUser (User *Usr, Value *Op, const APInt &OpConstVal, const DataLayout &DL)
 
static bool isKnownNonConstant (Value *V)
 Returns true if we can statically tell that this value will never be a "useful" constant.
 
static ConstantgetPredicateResult (CmpInst::Predicate Pred, Constant *C, const ValueLatticeElement &Val, const DataLayout &DL)
 

Variables

static const unsigned MaxProcessedPerValue = 500
 
lazy value info
 
lazy value Lazy Value Information Analysis
 
lazy value Lazy Value Information false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lazy-value-info"

Definition at line 47 of file LazyValueInfo.cpp.

Function Documentation

◆ AddNonNullPointer()

static void AddNonNullPointer ( Value Ptr,
NonNullPointerSet &  PtrSet 
)
static

Definition at line 625 of file LazyValueInfo.cpp.

References llvm::getUnderlyingObject(), and Ptr.

Referenced by AddNonNullPointersByInstruction().

◆ AddNonNullPointersByInstruction()

static void AddNonNullPointersByInstruction ( Instruction I,
NonNullPointerSet &  PtrSet 
)
static

Definition at line 631 of file LazyValueInfo.cpp.

References AddNonNullPointer(), I, and MI.

◆ constantFoldUser()

static ValueLatticeElement constantFoldUser ( User Usr,
Value Op,
const APInt OpConstVal,
const DataLayout DL 
)
static

◆ getFromRangeMetadata()

static ValueLatticeElement getFromRangeMetadata ( Instruction BBI)
static

◆ getPredicateResult()

static Constant * getPredicateResult ( CmpInst::Predicate  Pred,
Constant C,
const ValueLatticeElement Val,
const DataLayout DL 
)
static

◆ getRangeViaSLT()

static std::optional< ConstantRange > getRangeViaSLT ( CmpInst::Predicate  Pred,
APInt  RHS,
function_ref< std::optional< ConstantRange >(const APInt &)>  Fn 
)
static

◆ getValueFromOverflowCondition()

static ValueLatticeElement getValueFromOverflowCondition ( Value Val,
WithOverflowInst WO,
bool  IsTrueDest 
)
static

◆ hasSingleValue()

static bool hasSingleValue ( const ValueLatticeElement 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 75 of file LazyValueInfo.cpp.

References llvm::ValueLatticeElement::getConstantRange(), llvm::ValueLatticeElement::isConstant(), llvm::ValueLatticeElement::isConstantRange(), and llvm::ConstantRange::isSingleElement().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LazyValueInfoWrapperPass  ,
"lazy-value-info"  ,
"Lazy Value Information Analysis"  ,
false  ,
true   
)

◆ isKnownNonConstant()

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 1732 of file LazyValueInfo.cpp.

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

◆ isOperationFoldable()

static bool isOperationFoldable ( User Usr)
static

Definition at line 1342 of file LazyValueInfo.cpp.

Referenced by constantFoldUser().

◆ matchICmpOperand()

static bool matchICmpOperand ( APInt Offset,
Value LHS,
Value Val,
ICmpInst::Predicate  Pred 
)
static

◆ usesOperand()

static bool usesOperand ( User Usr,
Value Op 
)
static

Definition at line 1334 of file LazyValueInfo.cpp.

References llvm::is_contained(), and llvm::User::operands().

Variable Documentation

◆ Analysis

lazy value Lazy Value Information Analysis

Definition at line 62 of file LazyValueInfo.cpp.

◆ false

lazy value Lazy Value Information false

Definition at line 62 of file LazyValueInfo.cpp.

◆ info

lazy value info

◆ MaxProcessedPerValue

const unsigned MaxProcessedPerValue = 500
static

Definition at line 51 of file LazyValueInfo.cpp.