diff options
author | Daniel Neilson <dneilson@azul.com> | 2017-11-10 19:38:12 +0000 |
---|---|---|
committer | Daniel Neilson <dneilson@azul.com> | 2017-11-10 19:38:12 +0000 |
commit | 6e4aa1e48138182685431c76184dfc36e620aea2 (patch) | |
tree | 613f8dbbdb29e69bfaa89e665a87397d95809ee2 /llvm/lib/IR/IRBuilder.cpp | |
parent | bfd6c1c016c0fcb49144b0c16e6dd0a4387d52b9 (diff) | |
download | bcm5719-llvm-6e4aa1e48138182685431c76184dfc36e620aea2.tar.gz bcm5719-llvm-6e4aa1e48138182685431c76184dfc36e620aea2.zip |
Expand IRBuilder interface for atomic memcpy to require pointer alignments. (NFC)
Summary:
The specification of the @llvm.memcpy.element.unordered.atomic intrinsic requires
that the pointer arguments have alignments of at least the element size. The existing
IRBuilder interface to create a call to this intrinsic does not allow for providing
the alignment of these pointer args. Having an interface that makes it easy to
construct invalid intrinsic calls doesn't seem sensible, so this patch simply
adds the requirement that one provide the argument alignments when using IRBuilder
to create atomic memcpy calls.
llvm-svn: 317918
Diffstat (limited to 'llvm/lib/IR/IRBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 89338c8b849..027c0255bce 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -135,8 +135,13 @@ CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, } CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy( - Value *Dst, Value *Src, Value *Size, uint32_t ElementSize, MDNode *TBAATag, - MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) { + Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, Value *Size, + uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag, + MDNode *ScopeTag, MDNode *NoAliasTag) { + assert(DstAlign >= ElementSize && + "Pointer alignment must be at least element size"); + assert(SrcAlign >= ElementSize && + "Pointer alignment must be at least element size"); Dst = getCastedInt8PtrValue(Dst); Src = getCastedInt8PtrValue(Src); @@ -148,6 +153,10 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy( CallInst *CI = createCallHelper(TheFn, Ops, this); + // Set the alignment of the pointer args. + CI->addParamAttr(0, Attribute::getWithAlignment(CI->getContext(), DstAlign)); + CI->addParamAttr(1, Attribute::getWithAlignment(CI->getContext(), SrcAlign)); + // Set the TBAA info if present. if (TBAATag) CI->setMetadata(LLVMContext::MD_tbaa, TBAATag); |