1 ; RUN: opt -S < %s | FileCheck %s
3 ; Test to ensure that calls to the memcpy/memmove/memset intrinsics are auto-upgraded
4 ; to remove the alignment parameter in favour of align attributes on the pointer args.
6 ; Make sure a non-zero alignment is propagated
7 define void @test(i8* %p1, i8* %p2, i8* %p3) {
9 ; CHECK: call void @llvm.memset.p0i8.i64(i8* align 4 %p1, i8 55, i64 100, i1 false)
10 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %p1, i8* align 4 %p2, i64 50, i1 false)
11 ; CHECK: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 4 %p2, i8* align 4 %p3, i64 1000, i1 false)
12 call void @llvm.memset.p0i8.i64(i8* %p1, i8 55, i64 100, i32 4, i1 false)
13 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p1, i8* %p2, i64 50, i32 4, i1 false)
14 call void @llvm.memmove.p0i8.p0i8.i64(i8* %p2, i8* %p3, i64 1000, i32 4, i1 false)
18 ; Make sure that a zero alignment is handled properly
19 define void @test2(i8* %p1, i8* %p2, i8* %p3) {
21 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p1, i8 55, i64 100, i1 false)
22 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p1, i8* %p2, i64 50, i1 false)
23 ; CHECK: call void @llvm.memmove.p0i8.p0i8.i64(i8* %p2, i8* %p3, i64 1000, i1 false)
24 call void @llvm.memset.p0i8.i64(i8* %p1, i8 55, i64 100, i32 0, i1 false)
25 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p1, i8* %p2, i64 50, i32 0, i1 false)
26 call void @llvm.memmove.p0i8.p0i8.i64(i8* %p2, i8* %p3, i64 1000, i32 0, i1 false)
30 ; Make sure that attributes are not dropped
31 define void @test3(i8* %p1, i8* %p2, i8* %p3) {
33 ; CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull align 4 %p1, i8 signext 55, i64 zeroext 100, i1 immarg false)
34 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %p1, i8* readonly align 4 %p2, i64 zeroext 50, i1 immarg false)
35 ; CHECK: call void @llvm.memmove.p0i8.p0i8.i64(i8* nonnull align 4 %p2, i8* readonly align 4 %p3, i64 zeroext 1000, i1 immarg false)
36 call void @llvm.memset.p0i8.i64(i8* nonnull %p1, i8 signext 55, i64 zeroext 100, i32 signext 4, i1 immarg false)
37 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %p1, i8* readonly %p2, i64 zeroext 50, i32 signext 4, i1 immarg false)
38 call void @llvm.memmove.p0i8.p0i8.i64(i8* nonnull %p2, i8* readonly %p3, i64 zeroext 1000, i32 signext 4, i1 immarg false)
42 ; CHECK: declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
43 ; CHECK: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
44 ; CHECK: declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg)
45 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1)
46 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly , i8* nocapture readonly, i64, i32, i1)
47 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1)