diff options
Diffstat (limited to 'include/llvm/IR/IRBuilder.h')
-rw-r--r-- | include/llvm/IR/IRBuilder.h | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 5344a93efb335..e687ca689d466 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -438,22 +438,26 @@ public: /// \brief Create and insert an element unordered-atomic memcpy between the /// specified pointers. /// + /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers, respectively. + /// /// If the pointers aren't i8*, they will be converted. If a TBAA tag is /// specified, it will be added to the instruction. Likewise with alias.scope /// and noalias tags. CallInst *CreateElementUnorderedAtomicMemCpy( - Value *Dst, Value *Src, uint64_t Size, uint32_t ElementSize, - MDNode *TBAATag = nullptr, MDNode *TBAAStructTag = nullptr, - MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr) { + 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, Src, getInt64(Size), ElementSize, TBAATag, TBAAStructTag, ScopeTag, - NoAliasTag); + Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag, + TBAAStructTag, ScopeTag, NoAliasTag); } CallInst *CreateElementUnorderedAtomicMemCpy( - Value *Dst, Value *Src, Value *Size, uint32_t ElementSize, - MDNode *TBAATag = nullptr, MDNode *TBAAStructTag = nullptr, - MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr); + 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); /// \brief Create and insert a memmove between the specified /// pointers. @@ -1806,26 +1810,28 @@ public: /// \brief Create an invariant.group.barrier intrinsic call, that stops /// optimizer to propagate equality using invariant.group metadata. - /// If Ptr type is different from i8*, it's casted to i8* before call - /// and casted back to Ptr type after call. + /// If Ptr type is different from pointer to i8, it's casted to pointer to i8 + /// in the same address space before call and casted back to Ptr type after + /// call. Value *CreateInvariantGroupBarrier(Value *Ptr) { + assert(isa<PointerType>(Ptr->getType()) && + "invariant.group.barrier only applies to pointers."); + auto *PtrType = Ptr->getType(); + auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace()); + if (PtrType != Int8PtrTy) + Ptr = CreateBitCast(Ptr, Int8PtrTy); Module *M = BB->getParent()->getParent(); - Function *FnInvariantGroupBarrier = Intrinsic::getDeclaration(M, - Intrinsic::invariant_group_barrier); - - Type *ArgumentAndReturnType = FnInvariantGroupBarrier->getReturnType(); - assert(ArgumentAndReturnType == - FnInvariantGroupBarrier->getFunctionType()->getParamType(0) && - "InvariantGroupBarrier should take and return the same type"); - Type *PtrType = Ptr->getType(); + Function *FnInvariantGroupBarrier = Intrinsic::getDeclaration( + M, Intrinsic::invariant_group_barrier, {Int8PtrTy}); - bool PtrTypeConversionNeeded = PtrType != ArgumentAndReturnType; - if (PtrTypeConversionNeeded) - Ptr = CreateBitCast(Ptr, ArgumentAndReturnType); + assert(FnInvariantGroupBarrier->getReturnType() == Int8PtrTy && + FnInvariantGroupBarrier->getFunctionType()->getParamType(0) == + Int8PtrTy && + "InvariantGroupBarrier should take and return the same type"); CallInst *Fn = CreateCall(FnInvariantGroupBarrier, {Ptr}); - if (PtrTypeConversionNeeded) + if (PtrType != Int8PtrTy) return CreateBitCast(Fn, PtrType); return Fn; } |