1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00

[Alignment][NFC] Use Align with CreateElementUnorderedAtomicMemCpy

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, nicolasvasilache

Subscribers: hiraditya, jfb, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, csigg, arpith-jacob, mgester, lucyrfox, herhut, liufengdb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73041
This commit is contained in:
Guillaume Chatelet 2020-01-20 14:47:28 +01:00
parent 41fe602cc6
commit 355ab67a26
3 changed files with 39 additions and 16 deletions

View File

@ -569,21 +569,41 @@ public:
/// specified, it will be added to the instruction. Likewise with alias.scope
/// and noalias tags.
CallInst *CreateElementUnorderedAtomicMemCpy(
Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
uint64_t Size, uint32_t ElementSize, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr) {
return CreateElementUnorderedAtomicMemCpy(
Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
TBAAStructTag, ScopeTag, NoAliasTag);
}
CallInst *CreateElementUnorderedAtomicMemCpy(
Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, Value *Size,
Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
uint32_t ElementSize, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr);
/// FIXME: Remove this function once transition to Align is over.
/// Use the version that takes Align instead of this one.
LLVM_ATTRIBUTE_DEPRECATED(CallInst *CreateElementUnorderedAtomicMemCpy(
Value *Dst, unsigned DstAlign, Value *Src,
unsigned SrcAlign, uint64_t Size,
uint32_t ElementSize, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr,
MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr),
"Use the version that takes Align instead") {
return CreateElementUnorderedAtomicMemCpy(
Dst, Align(DstAlign), Src, Align(SrcAlign), getInt64(Size), ElementSize,
TBAATag, TBAAStructTag, ScopeTag, NoAliasTag);
}
/// FIXME: Remove this function once transition to Align is over.
/// Use the version that takes Align instead of this one.
LLVM_ATTRIBUTE_DEPRECATED(CallInst *CreateElementUnorderedAtomicMemCpy(
Value *Dst, unsigned DstAlign, Value *Src,
unsigned SrcAlign, Value *Size,
uint32_t ElementSize, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr,
MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr),
"Use the version that takes Align instead") {
return CreateElementUnorderedAtomicMemCpy(
Dst, Align(DstAlign), Src, Align(SrcAlign), Size, ElementSize, TBAATag,
TBAAStructTag, ScopeTag, NoAliasTag);
}
/// Create and insert a memmove between the specified
/// pointers.
///

View File

@ -201,7 +201,7 @@ CallInst *IRBuilderBase::CreateMemCpy(Value *Dst, MaybeAlign DstAlign,
}
CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, Value *Size,
Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
MDNode *ScopeTag, MDNode *NoAliasTag) {
assert(DstAlign >= ElementSize &&

View File

@ -1089,8 +1089,11 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
else {
// We cannot allow unaligned ops for unordered load/store, so reject
// anything where the alignment isn't at least the element size.
unsigned Align = std::min(SI->getAlignment(), LI->getAlignment());
if (Align < StoreSize)
const MaybeAlign StoreAlign = SI->getAlign();
const MaybeAlign LoadAlign = LI->getAlign();
if (StoreAlign == None || LoadAlign == None)
return false;
if (*StoreAlign < StoreSize || *LoadAlign < StoreSize)
return false;
// If the element.atomic memcpy is not lowered into explicit
@ -1104,8 +1107,8 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
// Note that unordered atomic loads/stores are *required* by the spec to
// have an alignment but non-atomic loads/stores may not.
NewCall = Builder.CreateElementUnorderedAtomicMemCpy(
StoreBasePtr, SI->getAlignment(), LoadBasePtr, LI->getAlignment(),
NumBytes, StoreSize);
StoreBasePtr, *StoreAlign, LoadBasePtr, *LoadAlign, NumBytes,
StoreSize);
}
NewCall->setDebugLoc(SI->getDebugLoc());