1- // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
1+ // RUN: %clang_cc1 -triple x86_64-linux -O1 %s \
22// RUN: -emit-llvm -o - | FileCheck %s
3- // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
3+ // RUN: %clang_cc1 -triple x86_64-linux -O1 %s \
44// RUN: -new-struct-path-tbaa -emit-llvm -o - | \
55// RUN: FileCheck -check-prefix=CHECK-NEW %s
66//
1010struct A { int i; };
1111struct B { A a[1 ]; };
1212struct C { int i; int x[3 ]; };
13+ struct D { int n; int arr[]; }; // flexible array member
14+ extern int AA[]; // incomplete array type
15+
16+ typedef int __attribute__ ((may_alias)) aliasing_int;
17+ typedef int __attribute__ ((may_alias)) aliasing_array[10];
18+ struct E { aliasing_int x[4 ]; aliasing_array y; };
1319
1420int foo (B *b) {
1521// CHECK-LABEL: _Z3fooP1B
@@ -28,25 +34,54 @@ int bar(C *c) {
2834
2935int bar2 (C *c) {
3036// CHECK-NEW-LABEL: _Z4bar2P1C
31- // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int :!.*]]
37+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x :!.*]]
3238 return c->x [2 ];
3339}
3440
3541int bar3 (C *c, int j) {
3642// CHECK-NEW-LABEL: _Z4bar3P1Ci
37- // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.* ]]
43+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x ]]
3844 return c->x [j];
3945}
4046
47+ int bar4 (D *d) {
48+ // CHECK-NEW-LABEL: _Z4bar4P1D
49+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]]
50+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]]
51+ return d->arr [d->n ];
52+ }
53+
54+ int bar5 (int j) {
55+ // CHECK-NEW-LABEL: _Z4bar5i
56+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]]
57+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]]
58+ return AA[2 ] + AA[j];
59+ }
60+
61+ int bar6 (E *e, int j) {
62+ // CHECK-NEW-LABEL: _Z4bar6P1Ei
63+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_E_x:!.*]]
64+ return e->x [j];
65+ }
66+
67+ int bar7 (E *e, int j) {
68+ // CHECK-NEW-LABEL: _Z4bar7P1Ei
69+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_E_y:!.*]]
70+ return e->y [j];
71+ }
72+
4173// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0}
4274// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0}
4375// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0}
4476
4577// CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"}
4678// CHECK-NEW-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"}
4779// CHECK-NEW-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0, i64 4}
48- // CHECK-NEW-DAG: [[TYPE_pointer:!.*]] = !{[[TYPE_char]], i64 8, !"any pointer"}
4980// CHECK-NEW-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 4, !"_ZTS1A", [[TYPE_int]], i64 0, i64 4}
5081// CHECK-NEW-DAG: [[TAG_A_i]] = !{[[TYPE_A]], [[TYPE_int]], i64 0, i64 4}
5182// CHECK-NEW-DAG: [[TYPE_C:!.*]] = !{[[TYPE_char]], i64 16, !"_ZTS1C", [[TYPE_int]], i64 0, i64 4, [[TYPE_int]], i64 4, i64 12}
52- // CHECK-NEW-DAG: [[TAG_C_i]] = !{[[TYPE_C:!.*]], [[TYPE_int:!.*]], i64 0, i64 4}
83+ // CHECK-NEW-DAG: [[TAG_C_i]] = !{[[TYPE_C]], [[TYPE_int]], i64 0, i64 4}
84+ // CHECK-NEW-DAG: [[TAG_C_x]] = !{[[TYPE_C]], [[TYPE_int]], i64 4, i64 4}
85+ // CHECK-NEW-DAG: [[TYPE_E:!.*]] = !{[[TYPE_char]], i64 56, !"_ZTS1E", [[TYPE_char]], i64 0, i64 16, [[TYPE_char]], i64 16, i64 40}
86+ // CHECK-NEW-DAG: [[TAG_E_x]] = !{[[TYPE_E]], [[TYPE_char]], i64 0, i64 4}
87+ // CHECK-NEW-DAG: [[TAG_E_y]] = !{[[TYPE_E]], [[TYPE_char]], i64 16, i64 4}
0 commit comments