LLVM 19.0.0git
Functions
llvm::VNCoercion Namespace Reference

Functions

bool canCoerceMustAliasedValueToLoad (Value *StoredVal, Type *LoadTy, const DataLayout &DL)
 Return true if CoerceAvailableValueToLoadType would succeed if it was called.
 
ValuecoerceAvailableValueToLoadType (Value *StoredVal, Type *LoadedTy, IRBuilderBase &IRB, const DataLayout &DL)
 If we saw a store of a value to memory, and then a load from a must-aliased pointer of a different type, try to coerce the stored value to the loaded type.
 
int analyzeLoadFromClobberingStore (Type *LoadTy, Value *LoadPtr, StoreInst *DepSI, const DataLayout &DL)
 This function determines whether a value for the pointer LoadPtr can be extracted from the store at DepSI.
 
int analyzeLoadFromClobberingLoad (Type *LoadTy, Value *LoadPtr, LoadInst *DepLI, const DataLayout &DL)
 This function determines whether a value for the pointer LoadPtr can be extracted from the load at DepLI.
 
int analyzeLoadFromClobberingMemInst (Type *LoadTy, Value *LoadPtr, MemIntrinsic *DepMI, const DataLayout &DL)
 This function determines whether a value for the pointer LoadPtr can be extracted from the memory intrinsic at DepMI.
 
ValuegetValueForLoad (Value *SrcVal, unsigned Offset, Type *LoadTy, Instruction *InsertPt, const DataLayout &DL)
 If analyzeLoadFromClobberingStore/Load returned an offset, this function can be used to actually perform the extraction of the bits from the store.
 
ConstantgetConstantValueForLoad (Constant *SrcVal, unsigned Offset, Type *LoadTy, const DataLayout &DL)
 
ValuegetMemInstValueForLoad (MemIntrinsic *SrcInst, unsigned Offset, Type *LoadTy, Instruction *InsertPt, const DataLayout &DL)
 If analyzeLoadFromClobberingMemInst returned an offset, this function can be used to actually perform the extraction of the bits from the memory intrinsic.
 
ConstantgetConstantMemInstValueForLoad (MemIntrinsic *SrcInst, unsigned Offset, Type *LoadTy, const DataLayout &DL)
 
static bool isFirstClassAggregateOrScalableType (Type *Ty)
 
static int analyzeLoadFromClobberingWrite (Type *LoadTy, Value *LoadPtr, Value *WritePtr, uint64_t WriteSizeInBits, const DataLayout &DL)
 This function is called when we have a memdep query of a load that ends up being a clobbering memory write (store, memset, memcpy, memmove).
 
static ValuegetStoreValueForLoadHelper (Value *SrcVal, unsigned Offset, Type *LoadTy, IRBuilderBase &Builder, const DataLayout &DL)
 

Function Documentation

◆ analyzeLoadFromClobberingLoad()

int llvm::VNCoercion::analyzeLoadFromClobberingLoad ( Type LoadTy,
Value LoadPtr,
LoadInst DepLI,
const DataLayout DL 
)

This function determines whether a value for the pointer LoadPtr can be extracted from the load at DepLI.

This function is called when we have a memdep query of a load that ends up being clobbered by another load.

On success, it returns the offset into DepLI that extraction would start. On failure, it returns -1.

See if the other load can feed into the second load.

Definition at line 232 of file VNCoercion.cpp.

References analyzeLoadFromClobberingWrite(), canCoerceMustAliasedValueToLoad(), DL, llvm::LoadInst::getPointerOperand(), llvm::Value::getType(), llvm::Type::isArrayTy(), and llvm::Type::isStructTy().

◆ analyzeLoadFromClobberingMemInst()

int llvm::VNCoercion::analyzeLoadFromClobberingMemInst ( Type LoadTy,
Value LoadPtr,
MemIntrinsic DepMI,
const DataLayout DL 
)

This function determines whether a value for the pointer LoadPtr can be extracted from the memory intrinsic at DepMI.

On success, it returns the offset into DepMI that extraction would start. On failure, it returns -1.

Definition at line 246 of file VNCoercion.cpp.

References analyzeLoadFromClobberingWrite(), llvm::ConstantFoldLoadFromConstPtr(), DL, llvm::Type::getScalarType(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::getUnderlyingObject(), llvm::ConstantInt::getZExtValue(), llvm::GlobalVariable::hasDefinitiveInitializer(), llvm::GlobalVariable::isConstant(), MI, and llvm::Offset.

◆ analyzeLoadFromClobberingStore()

int llvm::VNCoercion::analyzeLoadFromClobberingStore ( Type LoadTy,
Value LoadPtr,
StoreInst DepSI,
const DataLayout DL 
)

This function determines whether a value for the pointer LoadPtr can be extracted from the store at DepSI.

This function is called when we have a memdep query of a load that ends up being a clobbering store.

On success, it returns the offset into DepSI that extraction would start. On failure, it returns -1.

Definition at line 211 of file VNCoercion.cpp.

References analyzeLoadFromClobberingWrite(), canCoerceMustAliasedValueToLoad(), DL, llvm::StoreInst::getPointerOperand(), llvm::Value::getType(), llvm::StoreInst::getValueOperand(), and isFirstClassAggregateOrScalableType().

◆ analyzeLoadFromClobberingWrite()

static int llvm::VNCoercion::analyzeLoadFromClobberingWrite ( Type LoadTy,
Value LoadPtr,
Value WritePtr,
uint64_t  WriteSizeInBits,
const DataLayout DL 
)
static

This function is called when we have a memdep query of a load that ends up being a clobbering memory write (store, memset, memcpy, memmove).

This means that the write may provide bits used by the load but we can't be sure because the pointers don't must-alias.

Check this case to see if there is anything more we can do before we give up. This returns -1 if we have to give up, or a byte number in the stored value of the piece that feeds the load.

Definition at line 173 of file VNCoercion.cpp.

References DL, llvm::GetPointerBaseWithConstantOffset(), and isFirstClassAggregateOrScalableType().

Referenced by analyzeLoadFromClobberingLoad(), analyzeLoadFromClobberingMemInst(), and analyzeLoadFromClobberingStore().

◆ canCoerceMustAliasedValueToLoad()

bool llvm::VNCoercion::canCoerceMustAliasedValueToLoad ( Value StoredVal,
Type LoadTy,
const DataLayout DL 
)

Return true if CoerceAvailableValueToLoadType would succeed if it was called.

Return true if coerceAvailableValueToLoadType will succeed.

Definition at line 18 of file VNCoercion.cpp.

References llvm::alignTo(), DL, llvm::Type::getPointerAddressSpace(), llvm::Type::getScalarType(), llvm::Value::getType(), isFirstClassAggregateOrScalableType(), and llvm::Type::isTargetExtTy().

Referenced by analyzeLoadFromClobberingLoad(), analyzeLoadFromClobberingStore(), and coerceAvailableValueToLoadType().

◆ coerceAvailableValueToLoadType()

Value * llvm::VNCoercion::coerceAvailableValueToLoadType ( Value StoredVal,
Type LoadedTy,
IRBuilderBase Helper,
const DataLayout DL 
)

If we saw a store of a value to memory, and then a load from a must-aliased pointer of a different type, try to coerce the stored value to the loaded type.

If we saw a store of a value to memory, and then a load from a must-aliased pointer of a different type, try to coerce the stored value.

LoadedTy is the type of the load we want to replace. IRB is IRBuilder used to insert new instructions.

If we can't do it, return null.

Definition at line 76 of file VNCoercion.cpp.

References assert(), llvm::CallingConv::C, canCoerceMustAliasedValueToLoad(), llvm::ConstantFoldConstant(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateIntToPtr(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreatePtrToInt(), llvm::IRBuilderBase::CreateTruncOrBitCast(), DL, llvm::IntegerType::get(), llvm::Type::getContext(), llvm::Value::getType(), llvm::Type::isIntegerTy(), and llvm::Type::isPtrOrPtrVectorTy().

Referenced by getMemInstValueForLoad(), and getValueForLoad().

◆ getConstantMemInstValueForLoad()

Constant * llvm::VNCoercion::getConstantMemInstValueForLoad ( MemIntrinsic SrcInst,
unsigned  Offset,
Type LoadTy,
const DataLayout DL 
)

◆ getConstantValueForLoad()

Constant * llvm::VNCoercion::getConstantValueForLoad ( Constant SrcVal,
unsigned  Offset,
Type LoadTy,
const DataLayout DL 
)

◆ getMemInstValueForLoad()

Value * llvm::VNCoercion::getMemInstValueForLoad ( MemIntrinsic SrcInst,
unsigned  Offset,
Type LoadTy,
Instruction InsertPt,
const DataLayout DL 
)

If analyzeLoadFromClobberingMemInst returned an offset, this function can be used to actually perform the extraction of the bits from the memory intrinsic.

This function is called when we have a memdep query of a load that ends up being a clobbering mem intrinsic.

It inserts instructions to do so at InsertPt, and returns the extracted value.

Definition at line 360 of file VNCoercion.cpp.

References coerceAvailableValueToLoadType(), llvm::ConstantFoldLoadFromConstPtr(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateZExtOrBitCast(), DL, llvm::IntegerType::get(), llvm::Type::getContext(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::Value::getType(), and llvm::Offset.

Referenced by llvm::gvn::AvailableValue::MaterializeAdjustedValue().

◆ getStoreValueForLoadHelper()

static Value * llvm::VNCoercion::getStoreValueForLoadHelper ( Value SrcVal,
unsigned  Offset,
Type LoadTy,
IRBuilderBase Builder,
const DataLayout DL 
)
static

◆ getValueForLoad()

Value * llvm::VNCoercion::getValueForLoad ( Value SrcVal,
unsigned  Offset,
Type LoadTy,
Instruction InsertPt,
const DataLayout DL 
)

If analyzeLoadFromClobberingStore/Load returned an offset, this function can be used to actually perform the extraction of the bits from the store.

It inserts instructions to do so at InsertPt, and returns the extracted value.

Definition at line 335 of file VNCoercion.cpp.

References assert(), coerceAvailableValueToLoadType(), DL, getStoreValueForLoadHelper(), llvm::Value::getType(), and llvm::Offset.

Referenced by llvm::gvn::AvailableValue::MaterializeAdjustedValue().

◆ isFirstClassAggregateOrScalableType()

static bool llvm::VNCoercion::isFirstClassAggregateOrScalableType ( Type Ty)
static