1 ; RUN: opt -lint -disable-output < %s 2>&1 | FileCheck %s 2 3 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) nounwind argmemonly 4 5 define void @f_memcpy() { 6 entry: 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) 21 22 ret void 23 } 24 25 declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) nounwind argmemonly 26 27 define void @f_memmove() { 28 entry: 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) 43 44 ret void 45 } 46 47 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1) nounwind argmemonly 48 49 define void @f_memset() { 50 entry: 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) 59 60 ret void 61 } 62