1 ; RUN: opt -lint -disable-output < %s 2>&1 | FileCheck %s
3 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) nounwind argmemonly
5 define void @f_memcpy() {
7 %dst = alloca [1000 x i8], align 2
8 %src = alloca [1000 x i8], align 4
9 %dst.i8 = bitcast [1000 x i8]* %dst to i8*
10 %src.i8 = bitcast [1000 x i8]* %src to i8*
11 ; CHECK: Undefined behavior: Memory reference address is misaligned
12 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
13 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
14 ; CHECK: Undefined behavior: Memory reference address is misaligned
15 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 8 %src.i8, i32 200, i1 false)
16 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 8 %src.i8, i32 200, i1 false)
17 ; CHECK-NOT: @llvm.memcpy.p0i8.p0i8.i32
18 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
19 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 2 %src.i8, i32 200, i1 false)
20 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
25 declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) nounwind argmemonly
27 define void @f_memmove() {
29 %dst = alloca [1000 x i8], align 2
30 %src = alloca [1000 x i8], align 4
31 %dst.i8 = bitcast [1000 x i8]* %dst to i8*
32 %src.i8 = bitcast [1000 x i8]* %src to i8*
33 ; CHECK: Undefined behavior: Memory reference address is misaligned
34 ; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i32(i8* align 4 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
35 call void @llvm.memmove.p0i8.p0i8.i32(i8* align 4 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
36 ; CHECK: Undefined behavior: Memory reference address is misaligned
37 ; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 8 %src.i8, i32 200, i1 false)
38 call void @llvm.memmove.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 8 %src.i8, i32 200, i1 false)
39 ; CHECK-NOT: @llvm.memmove.p0i8.p0i8.i32
40 call void @llvm.memmove.p0i8.p0i8.i32(i8* align 1 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
41 call void @llvm.memmove.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 2 %src.i8, i32 200, i1 false)
42 call void @llvm.memmove.p0i8.p0i8.i32(i8* align 2 %dst.i8, i8* align 4 %src.i8, i32 200, i1 false)
47 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1) nounwind argmemonly
49 define void @f_memset() {
51 %dst = alloca [1000 x i8], align 2
52 %dst.i8 = bitcast [1000 x i8]* %dst to i8*
53 ; CHECK: Undefined behavior: Memory reference address is misaligned
54 ; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 %dst.i8, i8 55, i32 200, i1 false)
55 call void @llvm.memset.p0i8.i32(i8* align 4 %dst.i8, i8 55, i32 200, i1 false)
56 ; CHECK-NOT: @llvm.memset.p0i8.i32
57 call void @llvm.memset.p0i8.i32(i8* align 1 %dst.i8, i8 55, i32 200, i1 false)
58 call void @llvm.memset.p0i8.i32(i8* align 2 %dst.i8, i8 55, i32 200, i1 false)