1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -O2 -S -verify-memoryssa | FileCheck %s
4 ; performCallSlotOptzn in MemCpy should not exchange the calls to
5 ; @llvm.lifetime.start and @llvm.memcpy.
7 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) #1
8 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
9 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
11 define void @call_slot(i8* nocapture dereferenceable(16) %arg1) {
12 ; CHECK-LABEL: @call_slot(
14 ; CHECK-NEXT: [[TMP_SROA_3_0_ARG1_SROA_RAW_IDX:%.*]] = getelementptr inbounds i8, i8* [[ARG1:%.*]], i64 7
15 ; CHECK-NEXT: store i8 0, i8* [[TMP_SROA_3_0_ARG1_SROA_RAW_IDX]], align 1
16 ; CHECK-NEXT: ret void
19 %tmp = alloca [8 x i8], align 8
20 %tmp5 = bitcast [8 x i8]* %tmp to i8*
21 call void @llvm.lifetime.start.p0i8(i64 16, i8* %tmp5)
22 %tmp10 = getelementptr inbounds i8, i8* %tmp5, i64 7
23 store i8 0, i8* %tmp10, align 1
24 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %arg1, i8* align 8 %tmp5, i64 16, i1 false)
25 call void @llvm.lifetime.end.p0i8(i64 16, i8* %tmp5)
29 define void @memcpy_memcpy_across_lifetime(i8* noalias %p1, i8* noalias %p2, i8* noalias %p3) {
30 ; CHECK-LABEL: @memcpy_memcpy_across_lifetime(
31 ; CHECK-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
32 ; CHECK-NEXT: [[A8:%.*]] = getelementptr inbounds [16 x i8], [16 x i8]* [[A]], i64 0, i64 0
33 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull [[A8]])
34 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 1 dereferenceable(16) [[A8]], i8* noundef nonnull align 1 dereferenceable(16) [[P1:%.*]], i64 16, i1 false)
35 ; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 1 dereferenceable(16) [[P1]], i8* noundef nonnull align 1 dereferenceable(16) [[P2:%.*]], i64 16, i1 false)
36 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 1 dereferenceable(16) [[P2]], i8* noundef nonnull align 1 dereferenceable(16) [[A8]], i64 16, i1 false)
37 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull [[A8]])
38 ; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 1 dereferenceable(16) [[P3:%.*]], i8* noundef nonnull align 1 dereferenceable(16) [[P2]], i64 16, i1 false)
39 ; CHECK-NEXT: ret void
42 %a8 = bitcast [16 x i8]* %a to i8*
43 call void @llvm.lifetime.start.p0i8(i64 16, i8* %a8)
44 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a8, i8* %p1, i64 16, i1 false)
45 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p1, i8* %p2, i64 16, i1 false)
46 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p2, i8* %a8, i64 16, i1 false)
47 call void @llvm.lifetime.end.p0i8(i64 16, i8* %a8)
48 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p3, i8* %p2, i64 16, i1 false)
52 attributes #1 = { argmemonly nounwind }