1; RUN: opt -S < %s | FileCheck %s 2 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. 5 6; Make sure a non-zero alignment is propagated 7define void @test(i8* %p1, i8* %p2, i8* %p3) { 8; CHECK-LABEL: @test 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) 15 ret void 16} 17 18; Make sure that a zero alignment is handled properly 19define void @test2(i8* %p1, i8* %p2, i8* %p3) { 20; CHECK-LABEL: @test 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) 27 ret void 28} 29 30; CHECK: declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) 31; CHECK: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) 32; CHECK: declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) 33declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) 34declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly , i8* nocapture readonly, i64, i32, i1) 35declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) 36 37