[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / ms-anonymous-struct.c
blob91f807248a14b79254ecfacc55e873d40b7b6230
1 // RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s
3 // CHECK: %struct.test = type { i32, %struct.nested2, i32 }
4 // CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 }
5 // CHECK: %struct.nested1 = type { i32, i32 }
6 typedef struct nested1 {
7 int a1;
8 int b1;
9 } NESTED1;
11 struct nested2 {
12 int a;
13 NESTED1;
14 int b;
17 struct test {
18 int x;
19 struct nested2;
20 int y;
24 void foo(void)
26 // CHECK: %var = alloca %struct.test, align 4
27 struct test var;
29 // CHECK: getelementptr inbounds nuw %struct.test, ptr %var, i32 0, i32 1
30 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 0
31 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
32 var.a;
34 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %var, i32 0, i32 1
35 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 2
36 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
37 var.b;
39 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %var, i32 0, i32 1
40 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 1
41 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested1, ptr %{{.*}}, i32 0, i32 0
42 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
43 var.a1;
45 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}var, i32 0, i32 1
46 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 1
47 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested1, ptr %{{.*}}, i32 0, i32 1
48 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
49 var.b1;
51 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %var, i32 0, i32 0
52 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
53 var.x;
55 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %var, i32 0, i32 2
56 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
57 var.y;
60 void foo2(struct test* var)
62 // CHECK: alloca ptr, align
63 // CHECK-NEXT: store ptr %var, ptr %{{.*}}, align
64 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
65 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 1
66 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 0
67 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
68 var->a;
70 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
71 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 1
72 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 2
73 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
74 var->b;
76 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
77 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 1
78 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 1
79 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested1, ptr %{{.*}}, i32 0, i32 0
80 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
81 var->a1;
83 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
84 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 1
85 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested2, ptr %{{.*}}, i32 0, i32 1
86 // CHECK-NEXT: getelementptr inbounds nuw %struct.nested1, ptr %{{.*}}, i32 0, i32 1
87 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
88 var->b1;
90 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
91 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 0
92 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
93 var->x;
95 // CHECK-NEXT: load ptr, ptr %{{.*}}, align
96 // CHECK-NEXT: getelementptr inbounds nuw %struct.test, ptr %{{.*}}, i32 0, i32 2
97 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
98 var->y;