diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-11-18 22:17:24 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-11-18 22:17:24 +0000 |
commit | 8b170f7f290843dc3849eaa75b6f74a87a7a2de6 (patch) | |
tree | 698943dc126191d3c6399f9ee17050d56d3aea6b /test/Transforms/LoopIdiom | |
parent | c4bfc2d61dff2bb6b904d12b756f5b2ebda4ea35 (diff) |
Change memcpy/memset/memmove to have dest and source alignments.
Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html
These intrinsics currently have an explicit alignment argument which is
required to be a constant integer. It represents the alignment of the
source and dest, and so must be the minimum of those.
This change allows source and dest to each have their own alignments
by using the alignment attribute on their arguments. The alignment
argument itself is removed.
There are a few places in the code for which the code needs to be
checked by an expert as to whether using only src/dest alignment is
safe. For those places, they currently take the minimum of src/dest
alignments which matches the current behaviour.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 500, i32 8, i1 false)
will now read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dest, i8* align 8 %src, i32 500, i1 false)
For out of tree owners, I was able to strip alignment from calls using sed by replacing:
(call.*llvm\.memset.*)i32\ [0-9]*\,\ i1 false\)
with:
$1i1 false)
and similarly for memmove and memcpy.
I then added back in alignment to test cases which needed it.
A similar commit will be made to clang which actually has many differences in alignment as now
IRBuilder can generate different source/dest alignments on calls.
In IRBuilder itself, a new argument was added. Instead of calling:
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, /* isVolatile */ false)
you now call
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, SrcAlign, /* isVolatile */ false)
There is a temporary class (IntegerAlignment) which takes the source alignment and rejects
implicit conversion from bool. This is to prevent isVolatile here from passing its default
parameter to the source alignment.
Note, changes in future can now be made to codegen. I didn't change anything here, but this
change should enable better memcpy code sequences.
Reviewed by Hal Finkel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopIdiom')
-rw-r--r-- | test/Transforms/LoopIdiom/basic-address-space.ll | 2 | ||||
-rw-r--r-- | test/Transforms/LoopIdiom/basic.ll | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/test/Transforms/LoopIdiom/basic-address-space.ll b/test/Transforms/LoopIdiom/basic-address-space.ll index 67cabf36eec..c709b9acd58 100644 --- a/test/Transforms/LoopIdiom/basic-address-space.ll +++ b/test/Transforms/LoopIdiom/basic-address-space.ll @@ -7,7 +7,7 @@ target triple = "x86_64-apple-darwin10.0.0" define void @test10(i8 addrspace(2)* %X) nounwind ssp { ; CHECK-LABEL: @test10( ; CHECK: entry: -; CHECK-NEXT: call void @llvm.memset.p2i8.i16(i8 addrspace(2)* %X, i8 0, i16 10000, i32 1, i1 false) +; CHECK-NEXT: call void @llvm.memset.p2i8.i16(i8 addrspace(2)* align 1 %X, i8 0, i16 10000, i1 false) ; CHECK-NOT: store ; CHECK: ret void diff --git a/test/Transforms/LoopIdiom/basic.ll b/test/Transforms/LoopIdiom/basic.ll index 27a955175b5..529a8f9de8f 100644 --- a/test/Transforms/LoopIdiom/basic.ll +++ b/test/Transforms/LoopIdiom/basic.ll @@ -24,7 +24,7 @@ for.body: ; preds = %bb.nph, %for.body for.end: ; preds = %for.body, %entry ret void ; CHECK-LABEL: @test1( -; CHECK: call void @llvm.memset.p0i8.i64(i8* %Base, i8 0, i64 %Size, i32 1, i1 false) +; CHECK: call void @llvm.memset.p0i8.i64(i8* align 1 %Base, i8 0, i64 %Size, i1 false) ; CHECK-NOT: store } @@ -47,7 +47,7 @@ for.body.cont: for.end: ; preds = %for.body, %entry ret void ; CHECK-LABEL: @test1a( -; CHECK: call void @llvm.memset.p0i8.i64(i8* %Base, i8 0, i64 %Size, i32 1, i1 false) +; CHECK: call void @llvm.memset.p0i8.i64(i8* align 1 %Base, i8 0, i64 %Size, i1 false) ; CHECK-NOT: store } @@ -70,7 +70,7 @@ for.end: ; preds = %for.body, %entry ; CHECK-LABEL: @test2( ; CHECK: br i1 %cmp10, ; CHECK: %0 = shl i64 %Size, 2 -; CHECK: call void @llvm.memset.p0i8.i64(i8* %Base1, i8 1, i64 %0, i32 4, i1 false) +; CHECK: call void @llvm.memset.p0i8.i64(i8* align 4 %Base1, i8 1, i64 %0, i1 false) ; CHECK-NOT: store } @@ -119,7 +119,7 @@ for.body: ; preds = %bb.nph, %for.body for.end: ; preds = %for.body, %entry ret void ; CHECK-TODO-LABEL: @test4( -; CHECK-TODO: call void @llvm.memset.p0i8.i64(i8* %Base, i8 0, i64 100, i32 1, i1 false) +; CHECK-TODO: call void @llvm.memset.p0i8.i64(i8* %Base, i8 0, i64 100, i1 false) ; CHECK-TODO-NOT: store } @@ -166,7 +166,7 @@ for.body: ; preds = %bb.nph, %for.body for.end: ; preds = %for.body, %entry ret void ; CHECK-LABEL: @test6( -; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %Dest, i8* %Base, i64 %Size, i32 1, i1 false) +; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %Dest, i8* align 1 %Base, i64 %Size, i1 false) ; CHECK-NOT: store ; CHECK: ret void } @@ -191,7 +191,7 @@ for.body.cont: for.end: ; preds = %for.body, %entry ret void ; CHECK-LABEL: @test7( -; CHECK: call void @llvm.memset.p0i8.i64(i8* %Base, i8 0, i64 %Size, i32 1, i1 false) +; CHECK: call void @llvm.memset.p0i8.i64(i8* align 1 %Base, i8 0, i64 %Size, i1 false) ; CHECK-NOT: store } @@ -276,7 +276,7 @@ for.end13: ; preds = %for.inc10 ret void ; CHECK-LABEL: @test10( ; CHECK: entry: -; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* %X, i8 0, i64 10000, i32 1, i1 false) +; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 %X, i8 0, i64 10000, i1 false) ; CHECK-NOT: store ; CHECK: ret void } @@ -324,7 +324,7 @@ for.end: ; preds = %for.body ; CHECK-LABEL: @test12( ; CHECK-NEXT: entry: ; CHECK-NEXT: bitcast -; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* %P1, i8 0, i64 80000, i32 4, i1 false) +; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 %P1, i8 0, i64 80000, i1 false) ; CHECK-NOT: store ; CHECK: ret void } @@ -441,7 +441,7 @@ for.body: for.cond.cleanup: ret void ; CHECK-LABEL: @test15( -; CHECK: call void @llvm.memset.p0i8.i64(i8* %f1, i8 0, i64 262148, i32 4, i1 false) +; CHECK: call void @llvm.memset.p0i8.i64(i8* align 4 %f1, i8 0, i64 262148, i1 false) ; CHECK-NOT: store ; CHECK: ret void } |