1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2 ; RUN: opt -S -passes='sroa<preserve-cfg>' %s | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
3 ; RUN: opt -S -passes='sroa<modify-cfg>' %s | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
5 ; SROA should correctly offset `!tbaa.struct` metadata
7 %struct.Wishart = type { double, i32 }
8 declare void @llvm.memcpy.p0.p0.i64(ptr writeonly, ptr readonly, i64, i1 immarg)
9 declare double @subcall(double %g, i32 %m)
11 define double @bar(ptr %wishart) {
13 ; CHECK-NEXT: [[TMP_SROA_3:%.*]] = alloca [4 x i8], align 4
14 ; CHECK-NEXT: [[TMP_SROA_0_0_COPYLOAD:%.*]] = load double, ptr [[WISHART:%.*]], align 8, !tbaa.struct [[TBAA_STRUCT0:![0-9]+]]
15 ; CHECK-NEXT: [[TMP_SROA_2_0_WISHART_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[WISHART]], i64 8
16 ; CHECK-NEXT: [[TMP_SROA_2_0_COPYLOAD:%.*]] = load i32, ptr [[TMP_SROA_2_0_WISHART_SROA_IDX]], align 8, !tbaa.struct [[TBAA_STRUCT7:![0-9]+]]
17 ; CHECK-NEXT: [[TMP_SROA_3_0_WISHART_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[WISHART]], i64 12
18 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[TMP_SROA_3]], ptr align 4 [[TMP_SROA_3_0_WISHART_SROA_IDX]], i64 4, i1 false), !tbaa.struct [[TBAA_STRUCT8:![0-9]+]]
19 ; CHECK-NEXT: [[CALL:%.*]] = call double @subcall(double [[TMP_SROA_0_0_COPYLOAD]], i32 [[TMP_SROA_2_0_COPYLOAD]])
20 ; CHECK-NEXT: ret double [[CALL]]
22 %tmp = alloca %struct.Wishart, align 8
23 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %tmp, ptr align 8 %wishart, i64 16, i1 false), !tbaa.struct !2
24 %lg = load double, ptr %tmp, align 8, !tbaa !4
25 %m = getelementptr inbounds %struct.Wishart, ptr %tmp, i32 0, i32 1
26 %lm = load i32, ptr %m, align 8, !tbaa !8
27 %call = call double @subcall(double %lg, i32 %lm)
31 !2 = !{i64 0, i64 8, !3, i64 8, i64 4, !7}
33 !4 = !{!"double", !5, i64 0}
34 !5 = !{!"omnipotent char", !6, i64 0}
35 !6 = !{!"Simple C++ TBAA"}
37 !8 = !{!"int", !5, i64 0}
39 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
41 ; CHECK: [[TBAA_STRUCT0]] = !{i64 0, i64 8, !1, i64 8, i64 4, !5}
42 ; CHECK: [[META1:![0-9]+]] = !{!2, !2, i64 0}
43 ; CHECK: [[META2:![0-9]+]] = !{!"double", !3, i64 0}
44 ; CHECK: [[META3:![0-9]+]] = !{!"omnipotent char", !4, i64 0}
45 ; CHECK: [[META4:![0-9]+]] = !{!"Simple C++ TBAA"}
46 ; CHECK: [[META5:![0-9]+]] = !{!6, !6, i64 0}
47 ; CHECK: [[META6:![0-9]+]] = !{!"int", !3, i64 0}
48 ; CHECK: [[TBAA_STRUCT7]] = !{i64 0, i64 4, !5}
49 ; CHECK: [[TBAA_STRUCT8]] = !{}
51 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
52 ; CHECK-MODIFY-CFG: {{.*}}
53 ; CHECK-PRESERVE-CFG: {{.*}}