summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/IRBuilder.h51
-rw-r--r--llvm/lib/IR/IRBuilder.cpp29
-rw-r--r--llvm/lib/IR/Verifier.cpp4
3 files changed, 63 insertions, 21 deletions
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index e687ca689d4..97a36ce4cdc 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -420,20 +420,42 @@ public:
/// 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 *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
+ unsigned SrcAlign, uint64_t Size,
+ bool isVolatile = false, MDNode *TBAATag = nullptr,
+ MDNode *TBAAStructTag = nullptr,
+ MDNode *ScopeTag = nullptr,
+ MDNode *NoAliasTag = nullptr) {
+ return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
+ isVolatile, TBAATag, TBAAStructTag, ScopeTag,
+ NoAliasTag);
+ }
+
+ CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
+ unsigned SrcAlign, Value *Size,
+ bool isVolatile = false, MDNode *TBAATag = nullptr,
+ MDNode *TBAAStructTag = nullptr,
+ MDNode *ScopeTag = nullptr,
+ MDNode *NoAliasTag = nullptr);
+
+ // TODO: Old API. Remove this when no longer used.
CallInst *CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr,
MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr) {
- return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag,
+ return CreateMemCpy(Dst, Align, Src, Align, getInt64(Size), isVolatile, TBAATag,
TBAAStructTag, ScopeTag, NoAliasTag);
}
-
+ // TODO: Old API. Remove this when no longer used.
CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = nullptr,
MDNode *TBAAStructTag = nullptr,
MDNode *ScopeTag = nullptr,
- MDNode *NoAliasTag = nullptr);
+ MDNode *NoAliasTag = nullptr) {
+ return CreateMemCpy(Dst, Align, Src, Align, Size, isVolatile, TBAATag,
+ TBAAStructTag, ScopeTag, NoAliasTag);
+ }
/// \brief Create and insert an element unordered-atomic memcpy between the
/// specified pointers.
@@ -465,18 +487,35 @@ public:
/// 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 *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
+ uint64_t Size, bool isVolatile = false,
+ MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr,
+ MDNode *NoAliasTag = nullptr) {
+ return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size), isVolatile,
+ TBAATag, ScopeTag, NoAliasTag);
+ }
+
+ CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
+ Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
+ MDNode *ScopeTag = nullptr,
+ MDNode *NoAliasTag = nullptr);
+
+ // TODO: Old API. Remove this when no longer used.
CallInst *CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = nullptr,
MDNode *ScopeTag = nullptr,
MDNode *NoAliasTag = nullptr) {
- return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile,
+ return CreateMemMove(Dst, Align, Src, Align, getInt64(Size), isVolatile,
TBAATag, ScopeTag, NoAliasTag);
}
-
+ // TODO: Old API. Remove this when no longer used.
CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
bool isVolatile = false, MDNode *TBAATag = nullptr,
MDNode *ScopeTag = nullptr,
- MDNode *NoAliasTag = nullptr);
+ MDNode *NoAliasTag = nullptr) {
+ return CreateMemMove(Dst, Align, Src, Align, Size, isVolatile, TBAATag,
+ ScopeTag, NoAliasTag);
+ }
/// \brief Create a vector fadd reduction intrinsic of the source vector.
/// The first parameter is a scalar accumulator value for ordered reductions.
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 99795f54138..0085b82d4c8 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -108,10 +108,11 @@ CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
}
CallInst *IRBuilderBase::
-CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
- bool isVolatile, MDNode *TBAATag, MDNode *TBAAStructTag,
- MDNode *ScopeTag, MDNode *NoAliasTag) {
- assert((Align == 0 || isPowerOf2_32(Align)) && "Must be 0 or a power of 2");
+CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
+ Value *Size, bool isVolatile, MDNode *TBAATag,
+ MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) {
+ assert((DstAlign == 0 || isPowerOf2_32(DstAlign)) && "Must be 0 or a power of 2");
+ assert((SrcAlign == 0 || isPowerOf2_32(SrcAlign)) && "Must be 0 or a power of 2");
Dst = getCastedInt8PtrValue(Dst);
Src = getCastedInt8PtrValue(Src);
@@ -122,8 +123,11 @@ CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
CallInst *CI = createCallHelper(TheFn, Ops, this);
- if (Align > 0)
- cast<MemCpyInst>(CI)->setAlignment(Align);
+ auto* MCI = cast<MemCpyInst>(CI);
+ if (DstAlign > 0)
+ MCI->setDestAlignment(DstAlign);
+ if (SrcAlign > 0)
+ MCI->setSourceAlignment(SrcAlign);
// Set the TBAA info if present.
if (TBAATag)
@@ -184,10 +188,11 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
}
CallInst *IRBuilderBase::
-CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
- bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
+CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
+ Value *Size, bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
MDNode *NoAliasTag) {
- assert((Align == 0 || isPowerOf2_32(Align)) && "Must be 0 or a power of 2");
+ assert((DstAlign == 0 || isPowerOf2_32(DstAlign)) && "Must be 0 or a power of 2");
+ assert((SrcAlign == 0 || isPowerOf2_32(SrcAlign)) && "Must be 0 or a power of 2");
Dst = getCastedInt8PtrValue(Dst);
Src = getCastedInt8PtrValue(Src);
@@ -199,8 +204,10 @@ CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
CallInst *CI = createCallHelper(TheFn, Ops, this);
auto *MMI = cast<MemMoveInst>(CI);
- if (Align > 0)
- MMI->setAlignment(Align);
+ if (DstAlign > 0)
+ MMI->setDestAlignment(DstAlign);
+ if (SrcAlign > 0)
+ MMI->setSourceAlignment(SrcAlign);
// Set the TBAA info if present.
if (TBAATag)
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 92389b60545..27781e42bc5 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4064,10 +4064,6 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) {
Assert(IsValidAlignment(MTI->getSourceAlignment()),
"alignment of arg 1 of memory intrinsic must be 0 or a power of 2",
CS);
- // TODO: Remove this assert when we enhance IRBuilder API to create
- // memcpy/memmove with separate source & dest alignments.
- Assert(MTI->getSourceAlignment() == MTI->getDestAlignment(),
- "TEMPORARY: source and dest alignments must be the same");
}
Assert(isa<ConstantInt>(CS.getArgOperand(3)),
"isvolatile argument of memory intrinsics must be a constant int",
OpenPOWER on IntegriCloud