[AArch64] Add fpext and fpround costs (#119292)
[llvm-project.git] / clang / test / CodeGen / tbaa.c
blob0ab81f60a71941c56809271ee99299aaa9124d66
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=PATH
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
5 // Test TBAA metadata generated by front-end.
6 //
7 // NO-TBAA-NOT: !tbaa
9 typedef unsigned char uint8_t;
10 typedef unsigned short uint16_t;
11 typedef unsigned int uint32_t;
12 typedef unsigned long long uint64_t;
14 typedef enum {
15 RED_AUTO_32,
16 GREEN_AUTO_32,
17 BLUE_AUTO_32
18 } EnumAuto32;
20 typedef enum {
21 RED_AUTO_64,
22 GREEN_AUTO_64,
23 BLUE_AUTO_64 = 0x100000000ull
24 } EnumAuto64;
26 typedef enum : uint16_t {
27 RED_16,
28 GREEN_16,
29 BLUE_16
30 } Enum16;
32 typedef enum : uint8_t {
33 RED_8,
34 GREEN_8,
35 BLUE_8
36 } Enum8;
38 uint32_t g0(EnumAuto32 *E, uint32_t *val) {
39 // CHECK-LABEL: define{{.*}} i32 @g0(
40 // CHECK: store i32 5, ptr %{{.*}}, align 4, !tbaa [[TAG_i32:!.*]]
41 // CHECK: store i32 0, ptr %{{.*}}, align 4, !tbaa [[TAG_i32]]
42 // CHECK: load i32, ptr %{{.*}}, align 4, !tbaa [[TAG_i32]]
43 // PATH-LABEL: define{{.*}} i32 @g0(
44 // PATH: store i32 5, ptr %{{.*}}, align 4, !tbaa [[TAG_i32:!.*]]
45 // PATH: store i32 0, ptr %{{.*}}, align 4, !tbaa [[TAG_i32]]
46 // PATH: load i32, ptr %{{.*}}, align 4, !tbaa [[TAG_i32]]
47 *val = 5;
48 *E = RED_AUTO_32;
49 return *val;
52 uint64_t g1(EnumAuto64 *E, uint64_t *val) {
53 // CHECK-LABEL: define{{.*}} i64 @g1(
54 // CHECK: store i64 5, ptr %{{.*}}, align 8, !tbaa [[TAG_i64:!.*]]
55 // CHECK: store i64 0, ptr %{{.*}}, align 8, !tbaa [[TAG_long:!.*]]
56 // CHECK: load i64, ptr %{{.*}}, align 8, !tbaa [[TAG_i64]]
57 // PATH-LABEL: define{{.*}} i64 @g1(
58 // PATH: store i64 5, ptr %{{.*}}, align 8, !tbaa [[TAG_i64:!.*]]
59 // PATH: store i64 0, ptr %{{.*}}, align 8, !tbaa [[TAG_long:!.*]]
60 // PATH: load i64, ptr %{{.*}}, align 8, !tbaa [[TAG_i64]]
61 *val = 5;
62 *E = RED_AUTO_64;
63 return *val;
66 uint16_t g2(Enum16 *E, uint16_t *val) {
67 // CHECK-LABEL: define{{.*}} i16 @g2(
68 // CHECK: store i16 5, ptr %{{.*}}, align 2, !tbaa [[TAG_i16:!.*]]
69 // CHECK: store i16 0, ptr %{{.*}}, align 2, !tbaa [[TAG_i16]]
70 // CHECK: load i16, ptr %{{.*}}, align 2, !tbaa [[TAG_i16]]
71 // PATH-LABEL: define{{.*}} i16 @g2(
72 // PATH: store i16 5, ptr %{{.*}}, align 2, !tbaa [[TAG_i16:!.*]]
73 // PATH: store i16 0, ptr %{{.*}}, align 2, !tbaa [[TAG_i16]]
74 // PATH: load i16, ptr %{{.*}}, align 2, !tbaa [[TAG_i16]]
75 *val = 5;
76 *E = RED_16;
77 return *val;
80 uint8_t g3(Enum8 *E, uint8_t *val) {
81 // CHECK-LABEL: define{{.*}} i8 @g3(
82 // CHECK: store i8 5, ptr %{{.*}}, align 1, !tbaa [[TAG_i8:!.*]]
83 // CHECK: store i8 0, ptr %{{.*}}, align 1, !tbaa [[TAG_i8]]
84 // CHECK: load i8, ptr %{{.*}}, align 1, !tbaa [[TAG_i8]]
85 // PATH-LABEL: define{{.*}} i8 @g3(
86 // PATH: store i8 5, ptr %{{.*}}, align 1, !tbaa [[TAG_i8:!.*]]
87 // PATH: store i8 0, ptr %{{.*}}, align 1, !tbaa [[TAG_i8]]
88 // PATH: load i8, ptr %{{.*}}, align 1, !tbaa [[TAG_i8]]
89 *val = 5;
90 *E = RED_8;
91 return *val;
94 // CHECK: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_c_tbaa:!.*]],
95 // CHECK: [[TAG_c_tbaa]] = !{!"Simple C/C++ TBAA"}
96 // CHECK: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
97 // CHECK: [[TYPE_i32]] = !{!"int", [[TYPE_char]],
98 // CHECK: [[TAG_i64]] = !{[[TYPE_i64:!.*]], [[TYPE_i64]], i64 0}
99 // CHECK: [[TYPE_i64]] = !{!"long long", [[TYPE_char]],
100 // CHECK: [[TAG_long]] = !{[[TYPE_long:!.*]], [[TYPE_long]], i64 0}
101 // CHECK: [[TYPE_long]] = !{!"long", [[TYPE_char]],
102 // CHECK: [[TAG_i16]] = !{[[TYPE_i16:!.*]], [[TYPE_i16]], i64 0}
103 // CHECK: [[TYPE_i16]] = !{!"short", [[TYPE_char]],
104 // CHECK: [[TAG_i8]] = !{[[TYPE_i8:!.*]], [[TYPE_char]], i64 0}
106 // PATH: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_c_tbaa:!.*]],
107 // PATH: [[TAG_c_tbaa]] = !{!"Simple C/C++ TBAA"}
108 // PATH: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
109 // PATH: [[TYPE_i32]] = !{!"int", [[TYPE_char]],
110 // PATH: [[TAG_i64]] = !{[[TYPE_i64:!.*]], [[TYPE_i64]], i64 0}
111 // PATH: [[TYPE_i64]] = !{!"long long", [[TYPE_char]],
112 // PATH: [[TAG_long]] = !{[[TYPE_long:!.*]], [[TYPE_long]], i64 0}
113 // PATH: [[TYPE_long]] = !{!"long", [[TYPE_char]],
114 // PATH: [[TAG_i16]] = !{[[TYPE_i16:!.*]], [[TYPE_i16]], i64 0}
115 // PATH: [[TYPE_i16]] = !{!"short", [[TYPE_char]],
116 // PATH: [[TAG_i8]] = !{[[TYPE_i8:!.*]], [[TYPE_char]], i64 0}