From 139771f8b02d4885c2ab50032e0c9356d60a2b05 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 20 Jan 2020 17:11:00 +0100 Subject: [PATCH] [Alignment][NFC] Use Align with CreateElementUnorderedAtomicMemMove 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 Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73050 --- llvm/include/llvm/IR/IRBuilder.h | 42 +++++++++++++++++++++++--------- llvm/lib/IR/IRBuilder.cpp | 8 +++--- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 9341810c7b3b..b02945f98101 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -657,21 +657,41 @@ public: /// specified, it will be added to the instruction. Likewise with alias.scope /// and noalias tags. CallInst *CreateElementUnorderedAtomicMemMove( - 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 CreateElementUnorderedAtomicMemMove( - Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag, - TBAAStructTag, ScopeTag, NoAliasTag); - } - - CallInst *CreateElementUnorderedAtomicMemMove( - 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 *CreateElementUnorderedAtomicMemMove( + 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 CreateElementUnorderedAtomicMemMove( + 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 *CreateElementUnorderedAtomicMemMove( + 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 CreateElementUnorderedAtomicMemMove( + Dst, Align(DstAlign), Src, Align(SrcAlign), Size, ElementSize, TBAATag, + TBAAStructTag, ScopeTag, NoAliasTag); + } + /// Create a vector fadd reduction intrinsic of the source vector. /// The first parameter is a scalar accumulator value for ordered reductions. CallInst *CreateFAddReduce(Value *Acc, Value *Src); diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 2a6b2516d653..6e365a4f8345 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -276,7 +276,7 @@ CallInst *IRBuilderBase::CreateMemMove(Value *Dst, MaybeAlign DstAlign, } CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove( - 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 && @@ -295,10 +295,8 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove( CallInst *CI = createCallHelper(TheFn, Ops, this); // Set the alignment of the pointer args. - CI->addParamAttr( - 0, Attribute::getWithAlignment(CI->getContext(), Align(DstAlign))); - CI->addParamAttr( - 1, Attribute::getWithAlignment(CI->getContext(), Align(SrcAlign))); + CI->addParamAttr(0, Attribute::getWithAlignment(CI->getContext(), DstAlign)); + CI->addParamAttr(1, Attribute::getWithAlignment(CI->getContext(), SrcAlign)); // Set the TBAA info if present. if (TBAATag)