[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / malign-double.cpp
blob39ccde053b6e46d0ee2522c2350edf99abc0474a
1 // RUN: %clang_cc1 -malign-double -triple i386-unknown-linux -emit-llvm %s -o - \
2 // RUN: | FileCheck --check-prefix=CHECK-ON --check-prefix=CHECK %s
4 // RUN: %clang_cc1 -triple i386-unknown-linux -emit-llvm %s -o - \
5 // RUN: | FileCheck --check-prefix=CHECK-OFF --check-prefix=CHECK %s
7 /* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64
8 Software Conventions and Runtime Architecture Guide", version of
9 August 1999, Section 4.2, Figures 4-1 through 4-5.
10 A Union containing a double was also thrown in for good measure. */
12 struct S1 {
13 char c;
16 unsigned S1_align = __alignof(struct S1);
17 unsigned S1_size = sizeof(struct S1);
18 // CHECK: @S1_align ={{.*}} global i32 1, align 4
19 // CHECK: @S1_size ={{.*}} global i32 1, align 4
21 unsigned S1_c_offset = (unsigned) &((struct S1*) 0)->c;
22 // CHECK: @S1_c_offset ={{.*}} global i32 0, align 4
24 struct S2{
25 char c;
26 char d;
27 short s;
28 int n;
31 unsigned S2_align = __alignof(struct S2);
32 unsigned S2_size = sizeof(struct S2);
33 // CHECK: @S2_align ={{.*}} global i32 4, align 4
34 // CHECK: @S2_size ={{.*}} global i32 8, align 4
36 unsigned S2_c_offset = (unsigned) &((struct S2*) 0)->c;
37 unsigned S2_d_offset = (unsigned) &((struct S2*) 0)->d;
38 unsigned S2_s_offset = (unsigned) &((struct S2*) 0)->s;
39 unsigned S2_n_offset = (unsigned) &((struct S2*) 0)->n;
40 // CHECK: @S2_c_offset ={{.*}} global i32 0, align 4
41 // CHECK: @S2_d_offset ={{.*}} global i32 1, align 4
42 // CHECK: @S2_s_offset ={{.*}} global i32 2, align 4
43 // CHECK: @S2_n_offset ={{.*}} global i32 4, align 4
45 struct S3 {
46 char c;
47 short s;
50 unsigned S3_align = __alignof(struct S3);
51 unsigned S3_size = sizeof(struct S3);
52 // CHECK: @S3_align ={{.*}} global i32 2, align 4
53 // CHECK: @S3_size ={{.*}} global i32 4, align 4
55 unsigned S3_c_offset = (unsigned) &((struct S3*) 0)->c;
56 unsigned S3_s_offset = (unsigned) &((struct S3*) 0)->s;
57 // CHECK: @S3_c_offset ={{.*}} global i32 0, align 4
58 // CHECK: @S3_s_offset ={{.*}} global i32 2, align 4
60 struct S4 {
61 char c;
62 double d;
63 short s;
66 unsigned S4_align = __alignof(struct S4);
67 unsigned S4_size = sizeof(struct S4);
68 // CHECK-ON: @S4_align ={{.*}} global i32 8, align 4
69 // CHECK-ON: @S4_size ={{.*}} global i32 24, align 4
70 // CHECK-OFF: @S4_align ={{.*}} global i32 4, align 4
71 // CHECK-OFF: @S4_size ={{.*}} global i32 16, align 4
73 unsigned S4_c_offset = (unsigned) &((struct S4*) 0)->c;
74 unsigned S4_d_offset = (unsigned) &((struct S4*) 0)->d;
75 unsigned S4_s_offset = (unsigned) &((struct S4*) 0)->s;
76 // CHECK: @S4_c_offset ={{.*}} global i32 0, align 4
77 // CHECK-ON: @S4_d_offset ={{.*}} global i32 8, align 4
78 // CHECK-ON: @S4_s_offset ={{.*}} global i32 16, align 4
79 // CHECK-OFF: @S4_d_offset ={{.*}} global i32 4, align 4
80 // CHECK-OFF: @S4_s_offset ={{.*}} global i32 12, align 4
82 union S5 {
83 char c;
84 short s;
85 int j;
88 unsigned S5_align = __alignof(union S5);
89 unsigned S5_size = sizeof(union S5);
90 // CHECK: @S5_align ={{.*}} global i32 4, align 4
91 // CHECK: @S5_size ={{.*}} global i32 4, align 4
93 unsigned S5_c_offset = (unsigned) &((union S5*) 0)->c;
94 unsigned S5_s_offset = (unsigned) &((union S5*) 0)->s;
95 unsigned S5_j_offset = (unsigned) &((union S5*) 0)->j;
96 // CHECK: @S5_c_offset ={{.*}} global i32 0, align 4
97 // CHECK: @S5_s_offset ={{.*}} global i32 0, align 4
98 // CHECK: @S5_j_offset ={{.*}} global i32 0, align 4
100 union S6 {
101 char c;
102 double d;
105 unsigned S6_align = __alignof(union S6);
106 unsigned S6_size = sizeof(union S6);
107 // CHECK-ON: @S6_align ={{.*}} global i32 8, align 4
108 // CHECK-ON: @S6_size ={{.*}} global i32 8, align 4
109 // CHECK-OFF: @S6_align ={{.*}} global i32 4, align 4
110 // CHECK-OFF: @S6_size ={{.*}} global i32 8, align 4
112 unsigned S6_c_offset = (unsigned) &((union S6*) 0)->c;
113 unsigned S6_d_offset = (unsigned) &((union S6*) 0)->d;
114 // CHECK: @S6_c_offset ={{.*}} global i32 0, align 4
115 // CHECK: @S6_d_offset ={{.*}} global i32 0, align 4