• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 
f(bool * x)4 bool f(bool *x) {
5   return *x;
6 }
7 // CHECK-LABEL: define zeroext i1 @_Z1fPb
8 // CHECK: load i8, i8* %{{[^ ]*}}, align 1, !range [[RANGE_i8_0_2:![^ ]*]]
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, i8* %{{[^ ]*}}, align 1, !range
14 // NO-STRICT-ENUMS-NOT: !range
15 
16 enum e1 { };
g1(e1 * x)17 e1 g1(e1 *x) {
18   return *x;
19 }
20 // CHECK-LABEL: define i32 @_Z2g1P2e1
21 // CHECK: ret i32 0
22 
23 enum e2 { e2_a = 0 };
g2(e2 * x)24 e2 g2(e2 *x) {
25   return *x;
26 }
27 // CHECK-LABEL: define i32 @_Z2g2P2e2
28 // CHECK: ret i32 0
29 
30 enum e3 { e3_a = 16 };
g3(e3 * x)31 e3 g3(e3 *x) {
32   return *x;
33 }
34 // CHECK-LABEL: define i32 @_Z2g3P2e3
35 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_0_32:![^ ]*]]
36 
37 enum e4 { e4_a = -16};
g4(e4 * x)38 e4 g4(e4 *x) {
39   return *x;
40 }
41 // CHECK-LABEL: define i32 @_Z2g4P2e4
42 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m16_16:![^ ]*]]
43 
44 enum e5 { e5_a = -16, e5_b = 16};
g5(e5 * x)45 e5 g5(e5 *x) {
46   return *x;
47 }
48 // CHECK-LABEL: define i32 @_Z2g5P2e5
49 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
50 
51 enum e6 { e6_a = -1 };
g6(e6 * x)52 e6 g6(e6 *x) {
53   return *x;
54 }
55 // CHECK-LABEL: define i32 @_Z2g6P2e6
56 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m1_1:![^ ]*]]
57 
58 enum e7 { e7_a = -16, e7_b = 2};
g7(e7 * x)59 e7 g7(e7 *x) {
60   return *x;
61 }
62 // CHECK-LABEL: define i32 @_Z2g7P2e7
63 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m16_16]]
64 
65 enum e8 { e8_a = -17};
g8(e8 * x)66 e8 g8(e8 *x) {
67   return *x;
68 }
69 // CHECK-LABEL: define i32 @_Z2g8P2e8
70 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
71 
72 enum e9 { e9_a = 17};
g9(e9 * x)73 e9 g9(e9 *x) {
74   return *x;
75 }
76 // CHECK-LABEL: define i32 @_Z2g9P2e9
77 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_0_32]]
78 
79 enum e10 { e10_a = -16, e10_b = 32};
g10(e10 * x)80 e10 g10(e10 *x) {
81   return *x;
82 }
83 // CHECK-LABEL: define i32 @_Z3g10P3e10
84 // CHECK: load i32, i32* %x, align 4, !range [[RANGE_i32_m64_64:![^ ]*]]
85 
86 enum e11 {e11_a = 4294967296 };
g11(enum e11 * x)87 enum e11 g11(enum e11 *x) {
88   return *x;
89 }
90 // CHECK-LABEL: define i64 @_Z3g11P3e11
91 // CHECK: load i64, i64* %x, align {{[84]}}, !range [[RANGE_i64_0_2pow33:![^ ]*]]
92 
93 enum e12 {e12_a = 9223372036854775808U };
g12(enum e12 * x)94 enum e12 g12(enum e12 *x) {
95   return *x;
96 }
97 // CHECK-LABEL: define i64 @_Z3g12P3e12
98 // CHECK: load i64, i64* %x, align {{[84]}}
99 // CHECK-NOT: range
100 // CHECK: ret
101 
102 enum e13 : char {e13_a = -1 };
g13(e13 * x)103 e13 g13(e13 *x) {
104   return *x;
105 }
106 // CHECK-LABEL: define signext i8 @_Z3g13P3e13
107 // CHECK: load i8, i8* %x, align 1
108 // CHECK-NOT: range
109 // CHECK: ret
110 
111 enum class e14 {e14_a = 1};
g14(e14 * x)112 e14 g14(e14 *x) {
113   return *x;
114 }
115 // CHECK-LABEL: define i32 @_Z3g14P3e14
116 // CHECK: load i32, i32* %x, align 4
117 // CHECK-NOT: range
118 // CHECK: ret
119 
120 enum e15 { e15_a = 2147483648 };
g15(e15 * x)121 e15 g15(e15 *x) {
122   return *x;
123 }
124 // CHECK-LABEL: define i32 @_Z3g15P3e15
125 // CHECK: load i32, i32* %x, align 4
126 // CHECK-NOT: range
127 // CHECK: ret
128 
129 enum e16 { e16_a = -2147483648 };
g16(e16 * x)130 e16 g16(e16 *x) {
131   return *x;
132 }
133 // CHECK-LABEL: define i32 @_Z3g16P3e16
134 // CHECK: load i32, i32* %x, align 4
135 // CHECK-NOT: range
136 // CHECK: ret
137 
138 
139 // CHECK: [[RANGE_i8_0_2]] = !{i8 0, i8 2}
140 // CHECK: [[RANGE_i32_0_32]] = !{i32 0, i32 32}
141 // CHECK: [[RANGE_i32_m16_16]] = !{i32 -16, i32 16}
142 // CHECK: [[RANGE_i32_m32_32]] = !{i32 -32, i32 32}
143 // CHECK: [[RANGE_i32_m1_1]] = !{i32 -1, i32 1}
144 // CHECK: [[RANGE_i32_m64_64]] = !{i32 -64, i32 64}
145 // CHECK: [[RANGE_i64_0_2pow33]] = !{i64 0, i64 8589934592}
146