1 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -O1 -relaxed-aliasing -fstrict-enums -std=c++11 -o - | FileCheck %s
2 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -O1 -relaxed-aliasing -std=c++11 -o - | FileCheck --check-prefix=NO-STRICT-ENUMS %s
7 // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1fPb
8 // CHECK: load i8, ptr %{{[^ ]*}}, align 1, !range [[RANGE_i8_0_2:![0-9]+]], !noundef [[NOUNDEF:![0-9]+]]
10 // Only enum-tests follow. Ensure that after the bool test, no further range
11 // metadata shows up when strict enums are disabled.
12 // NO-STRICT-ENUMS-LABEL: define{{.*}} zeroext i1 @_Z1fPb
13 // NO-STRICT-ENUMS: load i8, ptr %{{[^ ]*}}, align 1, !range
14 // NO-STRICT-ENUMS-NOT: !range
20 // CHECK-LABEL: define{{.*}} i32 @_Z2g1P2e1
27 // CHECK-LABEL: define{{.*}} i32 @_Z2g2P2e2
30 enum e3
{ e3_a
= 16 };
34 // CHECK-LABEL: define{{.*}} i32 @_Z2g3P2e3
35 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_0_32:![0-9]+]], !noundef [[NOUNDEF]]
37 enum e4
{ e4_a
= -16};
41 // CHECK-LABEL: define{{.*}} i32 @_Z2g4P2e4
42 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16:![0-9]+]], !noundef [[NOUNDEF]]
44 enum e5
{ e5_a
= -16, e5_b
= 16};
48 // CHECK-LABEL: define{{.*}} i32 @_Z2g5P2e5
49 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![0-9]+]], !noundef [[NOUNDEF]]
51 enum e6
{ e6_a
= -1 };
55 // CHECK-LABEL: define{{.*}} i32 @_Z2g6P2e6
56 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m1_1:![0-9]+]], !noundef [[NOUNDEF]]
58 enum e7
{ e7_a
= -16, e7_b
= 2};
62 // CHECK-LABEL: define{{.*}} i32 @_Z2g7P2e7
63 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16]], !noundef [[NOUNDEF]]
65 enum e8
{ e8_a
= -17};
69 // CHECK-LABEL: define{{.*}} i32 @_Z2g8P2e8
70 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![0-9]+]], !noundef [[NOUNDEF]]
76 // CHECK-LABEL: define{{.*}} i32 @_Z2g9P2e9
77 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_0_32]], !noundef [[NOUNDEF]]
79 enum e10
{ e10_a
= -16, e10_b
= 32};
83 // CHECK-LABEL: define{{.*}} i32 @_Z3g10P3e10
84 // CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m64_64:![0-9]+]], !noundef [[NOUNDEF]]
86 enum e11
{e11_a
= 4294967296 };
87 enum e11
g11(enum e11
*x
) {
90 // CHECK-LABEL: define{{.*}} i64 @_Z3g11P3e11
91 // CHECK: load i64, ptr %x, align {{[84]}}, !range [[RANGE_i64_0_2pow33:![0-9]+]], !noundef [[NOUNDEF]]
93 enum e12
{e12_a
= 9223372036854775808U };
94 enum e12
g12(enum e12
*x
) {
97 // CHECK-LABEL: define{{.*}} i64 @_Z3g12P3e12
98 // CHECK: load i64, ptr %x, align {{[84]}}
102 enum e13
: char {e13_a
= -1 };
106 // CHECK-LABEL: define{{.*}} signext i8 @_Z3g13P3e13
107 // CHECK: load i8, ptr %x, align 1
111 enum class e14
{e14_a
= 1};
115 // CHECK-LABEL: define{{.*}} i32 @_Z3g14P3e14
116 // CHECK: load i32, ptr %x, align 4
120 enum e15
{ e15_a
= 2147483648 };
124 // CHECK-LABEL: define{{.*}} i32 @_Z3g15P3e15
125 // CHECK: load i32, ptr %x, align 4
129 enum e16
{ e16_a
= -2147483648 };
133 // CHECK-LABEL: define{{.*}} i32 @_Z3g16P3e16
134 // CHECK: load i32, ptr %x, align 4
139 // CHECK: [[RANGE_i8_0_2]] = !{i8 0, i8 2}
140 // CHECK: [[NOUNDEF]] = !{}
141 // CHECK: [[RANGE_i32_0_32]] = !{i32 0, i32 32}
142 // CHECK: [[RANGE_i32_m16_16]] = !{i32 -16, i32 16}
143 // CHECK: [[RANGE_i32_m32_32]] = !{i32 -32, i32 32}
144 // CHECK: [[RANGE_i32_m1_1]] = !{i32 -1, i32 1}
145 // CHECK: [[RANGE_i32_m64_64]] = !{i32 -64, i32 64}
146 // CHECK: [[RANGE_i64_0_2pow33]] = !{i64 0, i64 8589934592}