LLVM 17.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.
 
ValuegetStoreValueForLoad (Value *SrcVal, unsigned Offset, Type *LoadTy, Instruction *InsertPt, const DataLayout &DL)
 If analyzeLoadFromClobberingStore returned an offset, this function can be used to actually perform the extraction of the bits from the store.
 
ConstantgetConstantStoreValueForLoad (Constant *SrcVal, unsigned Offset, Type *LoadTy, const DataLayout &DL)
 
ValuegetLoadValueForLoad (LoadInst *SrcVal, unsigned Offset, Type *LoadTy, Instruction *InsertPt, const DataLayout &DL)
 If analyzeLoadFromClobberingLoad returned an offset, this function can be used to actually perform the extraction of the bits from the load, including any necessary load widening.
 
ConstantgetConstantLoadValueForLoad (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 unsigned getLoadLoadClobberFullWidthSize (const Value *MemLocBase, int64_t MemLocOffs, unsigned MemLocSize, const LoadInst *LI)
 Looks at a memory location for a load (specified by MemLocBase, Offs, and Size) and compares it against a load.
 
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 317 of file VNCoercion.cpp.

References analyzeLoadFromClobberingWrite(), assert(), canCoerceMustAliasedValueToLoad(), DL, getLoadLoadClobberFullWidthSize(), llvm::GetPointerBaseWithConstantOffset(), llvm::LoadInst::getPointerOperand(), llvm::Value::getType(), llvm::Type::isArrayTy(), llvm::Type::isIntegerTy(), llvm::LoadInst::isSimple(), llvm::Type::isStructTy(), and Size.

◆ 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 352 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::ConstantInt::get(), llvm::Type::getContext(), llvm::Value::getType(), llvm::Type::isIntegerTy(), and llvm::Type::isPtrOrPtrVectorTy().

Referenced by getMemInstValueForLoad(), and getStoreValueForLoad().

◆ getConstantLoadValueForLoad()

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

◆ getConstantMemInstValueForLoad()

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

◆ getConstantStoreValueForLoad()

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

Definition at line 453 of file VNCoercion.cpp.

References llvm::ConstantFoldLoadFromConst(), DL, and llvm::Offset.

Referenced by getConstantLoadValueForLoad().

◆ getLoadLoadClobberFullWidthSize()

static unsigned llvm::VNCoercion::getLoadLoadClobberFullWidthSize ( const Value MemLocBase,
int64_t  MemLocOffs,
unsigned  MemLocSize,
const LoadInst LI 
)
static

Looks at a memory location for a load (specified by MemLocBase, Offs, and Size) and compares it against a load.

If the specified load could be safely widened to a larger integer load that is 1) still efficient, 2) safe for the target, and 3) would provide the specified memory location value, then this function returns the size in bytes of the load width to use. If not, this returns zero.

Definition at line 236 of file VNCoercion.cpp.

References DL, llvm::LoadInst::getAlign(), llvm::Module::getDataLayout(), llvm::Instruction::getModule(), llvm::BasicBlock::getParent(), llvm::Instruction::getParent(), llvm::GetPointerBaseWithConstantOffset(), llvm::LoadInst::getPointerOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Function::hasFnAttribute(), llvm::LoadInst::isSimple(), llvm::NextPowerOf2(), and llvm::Align::value().

Referenced by analyzeLoadFromClobberingLoad().

◆ getLoadValueForLoad()

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

If analyzeLoadFromClobberingLoad returned an offset, this function can be used to actually perform the extraction of the bits from the load, including any necessary load widening.

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

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

This means that the load 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.

Definition at line 463 of file VNCoercion.cpp.

References assert(), llvm::bit_ceil(), Builder, llvm::dbgs(), DL, llvm::IntegerType::get(), llvm::PointerType::get(), llvm::LoadInst::getAlign(), llvm::Type::getContext(), llvm::Instruction::getDebugLoc(), llvm::Instruction::getParent(), llvm::Type::getPointerAddressSpace(), llvm::LoadInst::getPointerOperand(), getStoreValueForLoad(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::LoadInst::isSimple(), LLVM_DEBUG, llvm::Offset, llvm::Value::replaceAllUsesWith(), llvm::LoadInst::setAlignment(), and llvm::Value::takeName().

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

◆ 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 520 of file VNCoercion.cpp.

References Builder, coerceAvailableValueToLoadType(), llvm::ConstantFoldLoadFromConstPtr(), DL, llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::Type::getContext(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::Value::getType(), and llvm::Offset.

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

◆ getStoreValueForLoad()

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

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

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

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

This means that the store provides bits used by the load but the pointers don't must-alias. Check this case to see if there is anything more we can do before we give up.

Definition at line 445 of file VNCoercion.cpp.

References Builder, coerceAvailableValueToLoadType(), DL, getStoreValueForLoadHelper(), and llvm::Offset.

Referenced by getLoadValueForLoad(), and llvm::gvn::AvailableValue::MaterializeAdjustedValue().

◆ getStoreValueForLoadHelper()

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

◆ isFirstClassAggregateOrScalableType()

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