1
- // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
1
+ // RUN: %clang_cc1 -triple x86_64-linux -O1 %s \
2
2
// 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 \
4
4
// RUN: -new-struct-path-tbaa -emit-llvm -o - | \
5
5
// RUN: FileCheck -check-prefix=CHECK-NEW %s
6
6
//
10
10
struct A { int i; };
11
11
struct B { A a[1 ]; };
12
12
struct 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; };
13
19
14
20
int foo (B *b) {
15
21
// CHECK-LABEL: _Z3fooP1B
@@ -28,25 +34,54 @@ int bar(C *c) {
28
34
29
35
int bar2 (C *c) {
30
36
// CHECK-NEW-LABEL: _Z4bar2P1C
31
- // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int :!.*]]
37
+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x :!.*]]
32
38
return c->x [2 ];
33
39
}
34
40
35
41
int bar3 (C *c, int j) {
36
42
// CHECK-NEW-LABEL: _Z4bar3P1Ci
37
- // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.* ]]
43
+ // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x ]]
38
44
return c->x [j];
39
45
}
40
46
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
+
41
73
// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0}
42
74
// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0}
43
75
// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0}
44
76
45
77
// CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"}
46
78
// CHECK-NEW-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"}
47
79
// 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"}
49
80
// CHECK-NEW-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 4, !"_ZTS1A", [[TYPE_int]], i64 0, i64 4}
50
81
// CHECK-NEW-DAG: [[TAG_A_i]] = !{[[TYPE_A]], [[TYPE_int]], i64 0, i64 4}
51
82
// 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