summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Neilson <dneilson@azul.com>2018-01-27 17:59:10 +0000
committerDaniel Neilson <dneilson@azul.com>2018-01-27 17:59:10 +0000
commit551a4d6557d967cdd5200184633fff224e455ade (patch)
tree1fe0a49e5208b4c67b0c0eadb81e4541e43f99e4 /llvm/lib
parentc131a3e5484f3e29376cf52f36001cfe01ea657f (diff)
downloadbcm5719-llvm-551a4d6557d967cdd5200184633fff224e455ade.tar.gz
bcm5719-llvm-551a4d6557d967cdd5200184633fff224e455ade.zip
Add IRBuilder API to create memcpy/memmove calls with differing source and dest alignments
Summary: This change is step two in the series of changes to remove alignment argument from memcpy/memmove/memset in favour of alignment attributes. Steps: Step 1) Remove alignment parameter and create alignment parameter attributes for memcpy/memmove/memset. ( rL322965 ) Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing source and dest alignments. Step 3) Update Clang to use the new IRBuilder API. Step 4) Update Polly to use the new IRBuilder API. Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API, and those that use use MemIntrinsicInst::[get|set]Alignment() to use getDestAlignment() and getSourceAlignment() instead. Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the MemIntrinsicInst::[get|set]Alignment() methods. Reference http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html llvm-svn: 323597
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/IRBuilder.cpp29
-rw-r--r--llvm/lib/IR/Verifier.cpp4
2 files changed, 18 insertions, 15 deletions
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