[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / tbaa-pointers.c
blobb9ebe879820012851121b98f7b112e5f99456bc4
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
3 void p2unsigned(unsigned **ptr) {
4 // CHECK-LABEL: define void @p2unsigned(ptr noundef %ptr)
5 // CHECK-NEXT: entry:
6 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
7 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0:!.+]]
8 // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
9 // CHECK-NEXT: store ptr null, ptr [[BASE]], align 8, !tbaa [[ANY_POINTER_0]]
10 // CHECK-NEXT: ret void
12 *ptr = 0;
15 void p2unsigned_volatile(unsigned *volatile *ptr) {
16 // CHECK-LABEL: define void @p2unsigned_volatile(ptr noundef %ptr)
17 // CHECK-NEXT: entry:
18 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
19 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
20 // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
21 // CHECK-NEXT: store volatile ptr null, ptr [[BASE]], align 8, !tbaa [[ANY_POINTER_0]]
22 // CHECK-NEXT: ret void
24 *ptr = 0;
27 void p3int(int ***ptr) {
28 // CHECK-LABEL: define void @p3int(ptr noundef %ptr)
29 // CHECK-NEXT: entry:
30 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
31 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
32 // CHECK-NEXT: [[BASE_0:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
33 // CHECK-NEXT: [[BASE_1:%.+]] = load ptr, ptr [[BASE_0]], align 8, !tbaa [[ANY_POINTER_0]]
34 // CHECK-NEXT: store ptr null, ptr [[BASE_1]], align 8, !tbaa [[ANY_POINTER_0]]
35 // CHECK-NEXT: ret void
37 **ptr = 0;
40 void p4char(char ****ptr) {
41 // CHECK-LABEL: define void @p4char(ptr noundef %ptr)
42 // CHECK-NEXT: entry:
43 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
44 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
45 // CHECK-NEXT: [[BASE_0:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
46 // CHECK-NEXT: [[BASE_1:%.+]] = load ptr, ptr [[BASE_0]], align 8, !tbaa [[ANY_POINTER_0]]
47 // CHECK-NEXT: [[BASE_2:%.+]] = load ptr, ptr [[BASE_1]], align 8, !tbaa [[ANY_POINTER_0]]
48 // CHECK-NEXT: store ptr null, ptr [[BASE_2]], align 8, !tbaa [[ANY_POINTER_0]]
49 // CHECK-NEXT: ret void
51 ***ptr = 0;
54 void p4char_const1(const char ****ptr) {
55 // CHECK-LABEL: define void @p4char_const1(ptr noundef %ptr)
56 // CHECK-NEXT: entry:
57 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
58 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
59 // CHECK-NEXT: [[BASE_0:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
60 // CHECK-NEXT: [[BASE_1:%.+]] = load ptr, ptr [[BASE_0]], align 8, !tbaa [[ANY_POINTER_0]]
61 // CHECK-NEXT: [[BASE_2:%.+]] = load ptr, ptr [[BASE_1]], align 8, !tbaa [[ANY_POINTER_0]]
62 // CHECK-NEXT: store ptr null, ptr [[BASE_2]], align 8, !tbaa [[ANY_POINTER_0]]
63 // CHECK-NEXT: ret void
65 ***ptr = 0;
68 void p4char_const2(const char **const **ptr) {
69 // CHECK-LABEL: define void @p4char_const2(ptr noundef %ptr)
70 // CHECK-NEXT: entry:
71 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
72 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
73 // CHECK-NEXT: [[BASE_0:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
74 // CHECK-NEXT: [[BASE_1:%.+]] = load ptr, ptr [[BASE_0]], align 8, !tbaa [[ANY_POINTER_0]]
75 // CHECK-NEXT: [[BASE_2:%.+]] = load ptr, ptr [[BASE_1]], align 8, !tbaa [[ANY_POINTER_0]]
76 // CHECK-NEXT: store ptr null, ptr [[BASE_2]], align 8, !tbaa [[ANY_POINTER_0]]
77 // CHECK-NEXT: ret void
79 ***ptr = 0;
82 struct S1 {
83 int x;
84 int y;
87 void p2struct(struct S1 **ptr) {
88 // CHECK-LABEL: define void @p2struct(ptr noundef %ptr)
89 // CHECK-NEXT: entry:
90 // CHECK-NEXT: %ptr.addr = alloca ptr, align 8
91 // CHECK-NEXT: store ptr %ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
92 // CHECK-NEXT: [[BASE:%.+]] = load ptr, ptr %ptr.addr, align 8, !tbaa [[ANY_POINTER_0]]
93 // CHECK-NEXT: store ptr null, ptr [[BASE]], align 8, !tbaa [[ANY_POINTER_0]]
94 // CHECK-NEXT: ret void
96 *ptr = 0;
99 // CHECK: [[ANY_POINTER_0]] = !{[[ANY_POINTER:!.+]], [[ANY_POINTER]], i64 0}
100 // CHECK: [[ANY_POINTER]] = !{!"any pointer", [[CHAR:!.+]], i64 0}
101 // CHECK: [[CHAR]] = !{!"omnipotent char", [[TBAA_ROOT:!.+]], i64 0}
102 // CHECK: [[TBAA_ROOT]] = !{!"Simple C/C++ TBAA"}