diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -661,9 +661,13 @@ CallInst * CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src, - MaybeAlign SrcAlign, Value *Size, bool IsVolatile = false, + MaybeAlign SrcAlign, Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr, MDNode *TBAAStructTag = nullptr, - MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr); + MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr) { + return CreateMemTransferInst(Intrinsic::memcpy_inline, Dst, DstAlign, Src, + SrcAlign, Size, isVolatile, TBAATag, + TBAAStructTag, ScopeTag, NoAliasTag); + } /// Create and insert an element unordered-atomic memcpy between the /// specified pointers. @@ -692,7 +696,12 @@ MaybeAlign SrcAlign, Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr, - MDNode *NoAliasTag = nullptr); + MDNode *NoAliasTag = nullptr) { + return CreateMemTransferInst(Intrinsic::memmove, Dst, DstAlign, Src, + SrcAlign, Size, isVolatile, TBAATag, + /*TBAAStructTag=*/nullptr, ScopeTag, + NoAliasTag); + } /// \brief Create and insert an element unordered-atomic memmove between the /// specified pointers. diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -220,6 +220,9 @@ Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile, MDNode *TBAATag, MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) { + assert((IntrID == Intrinsic::memcpy || IntrID == Intrinsic::memcpy_inline || + IntrID == Intrinsic::memmove) && + "Unexpected intrinsic ID"); Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)}; Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); @@ -250,41 +253,6 @@ return CI; } -CallInst *IRBuilderBase::CreateMemCpyInline( - Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, - Value *Size, bool IsVolatile, MDNode *TBAATag, MDNode *TBAAStructTag, - MDNode *ScopeTag, MDNode *NoAliasTag) { - Value *Ops[] = {Dst, Src, Size, getInt1(IsVolatile)}; - Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()}; - Function *F = BB->getParent(); - Module *M = F->getParent(); - Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys); - - CallInst *CI = CreateCall(TheFn, Ops); - - auto *MCI = cast(CI); - if (DstAlign) - MCI->setDestAlignment(*DstAlign); - if (SrcAlign) - MCI->setSourceAlignment(*SrcAlign); - - // Set the TBAA info if present. - if (TBAATag) - MCI->setMetadata(LLVMContext::MD_tbaa, TBAATag); - - // Set the TBAA Struct info if present. - if (TBAAStructTag) - MCI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag); - - if (ScopeTag) - MCI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag); - - if (NoAliasTag) - MCI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); - - return CI; -} - CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy( Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag, @@ -323,37 +291,6 @@ return CI; } -CallInst *IRBuilderBase::CreateMemMove(Value *Dst, MaybeAlign DstAlign, - Value *Src, MaybeAlign SrcAlign, - Value *Size, bool isVolatile, - MDNode *TBAATag, MDNode *ScopeTag, - MDNode *NoAliasTag) { - Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)}; - Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; - Module *M = BB->getParent()->getParent(); - Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys); - - CallInst *CI = CreateCall(TheFn, Ops); - - auto *MMI = cast(CI); - if (DstAlign) - MMI->setDestAlignment(*DstAlign); - if (SrcAlign) - MMI->setSourceAlignment(*SrcAlign); - - // Set the TBAA info if present. - if (TBAATag) - CI->setMetadata(LLVMContext::MD_tbaa, TBAATag); - - if (ScopeTag) - CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag); - - if (NoAliasTag) - CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); - - return CI; -} - CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove( Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,