Debian Codegraph @

clang/test/CIR/CodeGen/align-load.c

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 struct S {
9 char b;
10 short s;
11 int i;
12 float f;
13 double d;
14 };
15
16 void accessStruct(struct S u) {
17 u.b;
18 u.s;
19 u.i;
20 u.f;
21 u.d;
22 }
23
24 // CIR: cir.func{{.*}} @accessStruct
25 // CIR: cir.load align(8)
26 // CIR: cir.load align(2)
27 // CIR: cir.load align(4)
28 // CIR: cir.load align(8)
29 // CIR: cir.load align(8)
30
31 // LLVM: define{{.*}} @accessStruct
32 // LLVM: load i8, ptr {{.*}}, align 8
33 // LLVM: load i16, ptr {{.*}}, align 2
34 // LLVM: load i32, ptr {{.*}}, align 4
35 // LLVM: load float, ptr {{.*}}, align 8
36 // LLVM: load double, ptr {{.*}}, align 8
37
38 // OGCG: define{{.*}} @accessStruct
39 // OGCG: load i8, ptr {{.*}}, align 8
40 // OGCG: load i16, ptr {{.*}}, align 2
41 // OGCG: load i32, ptr {{.*}}, align 4
42 // OGCG: load float, ptr {{.*}}, align 8
43 // OGCG: load double, ptr {{.*}}, align 8
44
45 union U {
46 char b;
47 short s;
48 int i;
49 float f;
50 double d;
51 };
52
53 void accessUnion(union U u) {
54 u.b;
55 u.s;
56 u.i;
57 u.f;
58 u.d;
59 }
60
61 // CIR: cir.func{{.*}} @accessUnion
62 // CIR: cir.load align(8)
63 // CIR: cir.load align(8)
64 // CIR: cir.load align(8)
65 // CIR: cir.load align(8)
66 // CIR: cir.load align(8)
67
68 // LLVM: define{{.*}} @accessUnion
69 // LLVM: load i8, ptr {{.*}}, align 8
70 // LLVM: load i16, ptr {{.*}}, align 8
71 // LLVM: load i32, ptr {{.*}}, align 8
72 // LLVM: load float, ptr {{.*}}, align 8
73 // LLVM: load double, ptr {{.*}}, align 8
74
75 // OGCG: define{{.*}} @accessUnion
76 // OGCG: load i8, ptr {{.*}}, align 8
77 // OGCG: load i16, ptr {{.*}}, align 8
78 // OGCG: load i32, ptr {{.*}}, align 8
79 // OGCG: load float, ptr {{.*}}, align 8
80 // OGCG: load double, ptr {{.*}}, align 8
81
82 // PR5279 - Reduced alignment on typedef.
83 typedef int myint __attribute__((aligned(1)));
84
85 int loadAligned(myint *p) {
86 return *p;
87 }
88
89 // CIR: cir.func{{.*}} @loadAligned
90 // CIR: cir.load align(1)
91
92 // LLVM: @loadAligned
93 // LLVM: load i32, ptr {{.*}}, align 1
94
95 // OGCG: @loadAligned
96 // OGCG: load i32, ptr {{.*}}, align 1