LLVM  8.0.1
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. More...
 
ValuecoerceAvailableValueToLoadType (Value *StoredVal, Type *LoadedTy, IRBuilder<> &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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
ConstantgetConstantMemInstValueForLoad (MemIntrinsic *SrcInst, unsigned Offset, Type *LoadTy, const DataLayout &DL)
 
template<class T , class HelperClass >
static TcoerceAvailableValueToLoadTypeHelper (T *StoredVal, Type *LoadedTy, HelperClass &Helper, const DataLayout &DL)
 
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). More...
 
template<class T , class HelperClass >
static TgetStoreValueForLoadHelper (T *SrcVal, unsigned Offset, Type *LoadTy, HelperClass &Helper, const DataLayout &DL)
 
template<class T , class HelperClass >
TgetMemInstValueForLoadHelper (MemIntrinsic *SrcInst, unsigned Offset, Type *LoadTy, HelperClass &Helper, 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 225 of file VNCoercion.cpp.

References analyzeLoadFromClobberingWrite(), assert(), llvm::MemoryDependenceResults::getLoadLoadClobberFullWidthSize(), llvm::GetPointerBaseWithConstantOffset(), llvm::LoadInst::getPointerOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::DataLayout::getTypeStoreSize(), llvm::Type::isArrayTy(), llvm::Type::isIntegerTy(), llvm::LoadInst::isSimple(), llvm::Type::isStructTy(), and Size.

Referenced by alwaysAvailable(), and reportMayClobberedLoad().

◆ analyzeLoadFromClobberingMemInst()

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

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

References analyzeLoadFromClobberingWrite(), llvm::StoreInst::getPointerOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::StoreInst::getValueOperand(), llvm::Type::isArrayTy(), and llvm::Type::isStructTy().

Referenced by alwaysAvailable(), and reportMayClobberedLoad().

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

References llvm::GetPointerBaseWithConstantOffset(), llvm::DataLayout::getTypeSizeInBits(), llvm::Type::isArrayTy(), and llvm::Type::isStructTy().

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

References llvm::alignTo(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::Type::isArrayTy(), llvm::DataLayout::isNonIntegralPointerType(), and llvm::Type::isStructTy().

Referenced by coerceAvailableValueToLoadTypeHelper(), and reportMayClobberedLoad().

◆ coerceAvailableValueToLoadType()

Value * llvm::VNCoercion::coerceAvailableValueToLoadType ( Value StoredVal,
Type LoadedTy,
IRBuilder<> &  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.

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

References coerceAvailableValueToLoadTypeHelper().

◆ coerceAvailableValueToLoadTypeHelper()

template<class T , class HelperClass >
static T* llvm::VNCoercion::coerceAvailableValueToLoadTypeHelper ( T StoredVal,
Type LoadedTy,
HelperClass &  Helper,
const DataLayout DL 
)
static

◆ 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 
)

Definition at line 489 of file VNCoercion.cpp.

References F().

Referenced by alwaysAvailable().

◆ getConstantStoreValueForLoad()

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

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

References assert(), llvm::dbgs(), llvm::IntegerType::get(), llvm::PointerType::get(), llvm::LoadInst::getAlignment(), llvm::Type::getContext(), llvm::Instruction::getDebugLoc(), llvm::Instruction::getParent(), llvm::Type::getPointerAddressSpace(), llvm::LoadInst::getPointerOperand(), getStoreValueForLoad(), llvm::Value::getType(), llvm::DataLayout::getTypeStoreSize(), llvm::DataLayout::isBigEndian(), llvm::Type::isIntegerTy(), llvm::isPowerOf2_32(), llvm::LoadInst::isSimple(), LLVM_DEBUG, llvm::NextPowerOf2(), 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 481 of file VNCoercion.cpp.

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

◆ getMemInstValueForLoadHelper()

template<class T , class HelperClass >
T* llvm::VNCoercion::getMemInstValueForLoadHelper ( MemIntrinsic SrcInst,
unsigned  Offset,
Type LoadTy,
HelperClass &  Helper,
const DataLayout DL 
)

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

References coerceAvailableValueToLoadTypeHelper(), and getStoreValueForLoadHelper().

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

◆ getStoreValueForLoadHelper()

template<class T , class HelperClass >
static T* llvm::VNCoercion::getStoreValueForLoadHelper ( T SrcVal,
unsigned  Offset,
Type LoadTy,
HelperClass &  Helper,
const DataLayout DL 
)
static