2010-04-04 11:10:52 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm < %s| FileCheck %s
|
2008-07-22 08:26:45 +08:00
|
|
|
|
2011-04-17 08:40:24 +08:00
|
|
|
// CHECK: @test1
|
2010-04-04 11:10:52 +08:00
|
|
|
// CHECK: call void @llvm.memset.p0i8.i32
|
|
|
|
// CHECK: call void @llvm.memset.p0i8.i32
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
|
|
|
|
// CHECK: call void @llvm.memmove.p0i8.p0i8.i32
|
|
|
|
// CHECK-NOT: __builtin
|
|
|
|
// CHECK: ret
|
2011-04-17 08:40:24 +08:00
|
|
|
int test1(int argc, char **argv) {
|
2008-07-22 08:26:45 +08:00
|
|
|
unsigned char a = 0x11223344;
|
|
|
|
unsigned char b = 0x11223344;
|
|
|
|
__builtin_bzero(&a, sizeof(a));
|
|
|
|
__builtin_memset(&a, 0, sizeof(a));
|
|
|
|
__builtin_memcpy(&a, &b, sizeof(a));
|
|
|
|
__builtin_memmove(&a, &b, sizeof(a));
|
|
|
|
return 0;
|
|
|
|
}
|
2011-04-17 08:40:24 +08:00
|
|
|
|
|
|
|
// rdar://9289468
|
|
|
|
|
|
|
|
// CHECK: @test2
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
|
|
|
|
char* test2(char* a, char* b) {
|
|
|
|
return __builtin_memcpy(a, b, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @test3
|
|
|
|
// CHECK: call void @llvm.memset
|
|
|
|
void test3(char *P) {
|
|
|
|
__builtin___memset_chk(P, 42, 128, 128);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @test4
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
void test4(char *P, char *Q) {
|
|
|
|
__builtin___memcpy_chk(P, Q, 128, 128);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @test5
|
|
|
|
// CHECK: call void @llvm.memmove
|
|
|
|
void test5(char *P, char *Q) {
|
|
|
|
__builtin___memmove_chk(P, Q, 128, 128);
|
|
|
|
}
|
2011-04-21 07:14:50 +08:00
|
|
|
|
|
|
|
// CHECK: @test6
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
int test6(char *X) {
|
|
|
|
return __builtin___memcpy_chk(X, X, 42, 42) != 0;
|
|
|
|
}
|
2012-03-04 08:52:12 +08:00
|
|
|
|
|
|
|
// CHECK: @test7
|
|
|
|
// PR12094
|
|
|
|
int test7(int *p) {
|
2012-03-04 08:56:24 +08:00
|
|
|
struct snd_pcm_hw_params_t* hwparams; // incomplete type.
|
2015-11-19 13:55:59 +08:00
|
|
|
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memset{{.*}} align 4 {{.*}}256, i1 false)
|
2012-03-04 08:52:12 +08:00
|
|
|
__builtin_memset(p, 0, 256); // Should be alignment = 4
|
2012-03-04 08:56:24 +08:00
|
|
|
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memset{{.*}} align 1 {{.*}}256, i1 false)
|
2012-03-04 08:56:24 +08:00
|
|
|
__builtin_memset((char*)p, 0, 256); // Should be alignment = 1
|
2012-03-04 08:52:12 +08:00
|
|
|
|
|
|
|
__builtin_memset(hwparams, 0, 256); // No crash alignment = 1
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memset{{.*}} align 1{{.*}}256, i1 false)
|
2012-03-04 08:52:12 +08:00
|
|
|
}
|
2012-08-23 11:10:17 +08:00
|
|
|
|
|
|
|
// <rdar://problem/11314941>
|
|
|
|
// Make sure we don't over-estimate the alignment of fields of
|
|
|
|
// packed structs.
|
|
|
|
struct PS {
|
|
|
|
int modes[4];
|
|
|
|
} __attribute__((packed));
|
|
|
|
struct PS ps;
|
|
|
|
void test8(int *arg) {
|
|
|
|
// CHECK: @test8
|
Change memcpy/memove/memset to have dest and source alignment attributes.
Summary:
This change is step three 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, rC322964, rL322963 )
Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing
source and dest alignments. ( rL323597 )
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
Reviewers: rjmccall
Subscribers: jyknight, nemanjai, nhaehnle, javed.absar, sbc100, aheejin, kbarton, fedor.sergeev, cfe-commits
Differential Revision: https://reviews.llvm.org/D41677
llvm-svn: 323617
2018-01-29 01:27:45 +08:00
|
|
|
// CHECK: call void @llvm.memcpy{{.*}} align 4 {{.*}} align 1 {{.*}} 16, i1 false)
|
2012-08-23 11:10:17 +08:00
|
|
|
__builtin_memcpy(arg, ps.modes, sizeof(struct PS));
|
|
|
|
}
|
|
|
|
|
|
|
|
__attribute((aligned(16))) int x[4], y[4];
|
|
|
|
void test9() {
|
|
|
|
// CHECK: @test9
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memcpy{{.*}} align 16 {{.*}} align 16 {{.*}} 16, i1 false)
|
2012-08-23 11:10:17 +08:00
|
|
|
__builtin_memcpy(x, y, sizeof(y));
|
|
|
|
}
|