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)
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
15 void p2unsigned_volatile(unsigned *volatile *ptr
) {
16 // CHECK-LABEL: define void @p2unsigned_volatile(ptr noundef %ptr)
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
27 void p3int(int ***ptr
) {
28 // CHECK-LABEL: define void @p3int(ptr noundef %ptr)
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
40 void p4char(char ****ptr
) {
41 // CHECK-LABEL: define void @p4char(ptr noundef %ptr)
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
54 void p4char_const1(const char ****ptr
) {
55 // CHECK-LABEL: define void @p4char_const1(ptr noundef %ptr)
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
68 void p4char_const2(const char **const **ptr
) {
69 // CHECK-LABEL: define void @p4char_const2(ptr noundef %ptr)
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
87 void p2struct(struct S1
**ptr
) {
88 // CHECK-LABEL: define void @p2struct(ptr noundef %ptr)
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
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"}