[llvm] 46b9563 - [Alignment][NFC] Use Align with CreateElementUnorderedAtomicMemCpy
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 06:44:41 PST 2020
Author: Guillaume Chatelet
Date: 2020-01-20T15:39:45+01:00
New Revision: 46b9563cf68a8a094276b471632fa15eec954d53
URL: https://github.com/llvm/llvm-project/commit/46b9563cf68a8a094276b471632fa15eec954d53
DIFF: https://github.com/llvm/llvm-project/commit/46b9563cf68a8a094276b471632fa15eec954d53.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/IRBuilder.cpp
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 6006d74fc59d..6f6d6db31726 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -569,20 +569,40 @@ class IRBuilderBase {
/// 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,
+ 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) {
+ 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, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
- TBAAStructTag, ScopeTag, NoAliasTag);
+ Dst, Align(DstAlign), Src, Align(SrcAlign), getInt64(Size), ElementSize,
+ TBAATag, TBAAStructTag, ScopeTag, NoAliasTag);
}
- 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);
+ /// 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.
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 30b558a655cb..32daf40f390b 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -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 &&
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index b77843d7cd71..5bdbf303aaa8 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -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());
More information about the llvm-commits
mailing list