Skip to content

Commit 0cd7870

Browse files
committed
[InstCombine] Add memcpy test with !tbaa.struct with multiple fields.
Add an additional test with a struct with multiple fields. (cherry-picked from 9dd8ba4)
1 parent 5d7e964 commit 0cd7870

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,55 @@ define ptr @test2() {
3535
ret ptr %tmp
3636
}
3737

38+
define void @test3_multiple_fields(ptr nocapture %a, ptr nocapture %b) {
39+
; CHECK-LABEL: @test3_multiple_fields(
40+
; CHECK-NEXT: entry:
41+
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[B:%.*]], align 4
42+
; CHECK-NEXT: store i64 [[TMP0]], ptr [[A:%.*]], align 4
43+
; CHECK-NEXT: ret void
44+
;
45+
entry:
46+
tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 8, i1 false), !tbaa.struct !6
47+
ret void
48+
}
49+
50+
define void @test4_multiple_copy_first_field(ptr nocapture %a, ptr nocapture %b) {
51+
; CHECK-LABEL: @test4_multiple_copy_first_field(
52+
; CHECK-NEXT: entry:
53+
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[B:%.*]], align 4
54+
; CHECK-NEXT: store i32 [[TMP0]], ptr [[A:%.*]], align 4
55+
; CHECK-NEXT: ret void
56+
;
57+
entry:
58+
tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 4, i1 false), !tbaa.struct !6
59+
ret void
60+
}
61+
62+
define void @test5_multiple_copy_more_than_first_field(ptr nocapture %a, ptr nocapture %b) {
63+
; CHECK-LABEL: @test5_multiple_copy_more_than_first_field(
64+
; CHECK-NEXT: entry:
65+
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[B:%.*]], align 4
66+
; CHECK-NEXT: store i32 [[TMP0]], ptr [[A:%.*]], align 4
67+
; CHECK-NEXT: ret void
68+
;
69+
entry:
70+
tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 4, i1 false), !tbaa.struct !7
71+
ret void
72+
}
73+
3874
!0 = !{!"Simple C/C++ TBAA"}
3975
!1 = !{!"omnipotent char", !0}
4076
!2 = !{!5, !5, i64 0}
4177
!3 = !{i64 0, i64 4, !2}
4278
!4 = !{i64 0, i64 8, null}
4379
!5 = !{!"float", !0}
80+
!6 = !{i64 0, i64 4, !2, i64 4, i64 4, !2}
81+
!7 = !{i64 0, i64 2, !2, i64 4, i64 6, !2}
4482

4583
;.
4684
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
4785
;.
48-
; CHECK: [[TBAA0]] = !{!1, !1, i64 0}
49-
; CHECK: [[META1:![0-9]+]] = !{!"float", !2}
50-
; CHECK: [[META2:![0-9]+]] = !{!"Simple C/C++ TBAA"}
86+
; CHECK: [[TBAA0]] = !{[[META1:![0-9]+]], [[META1]], i64 0}
87+
; CHECK: [[META1]] = !{!"float", [[META2:![0-9]+]]}
88+
; CHECK: [[META2]] = !{!"Simple C/C++ TBAA"}
5189
;.

0 commit comments

Comments
 (0)