Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / catch-implicit-signed-integer-truncations-incdec.c
blob84183d7eb72a08f7c2fc61194eb148611b4473b0
1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NOSANITIZE
3 // RUN: %clang_cc1 -fsanitize=implicit-signed-integer-truncation -fno-sanitize-recover=implicit-signed-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
4 // RUN: %clang_cc1 -fsanitize=implicit-signed-integer-truncation -fsanitize-recover=implicit-signed-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
5 // RUN: %clang_cc1 -fsanitize=implicit-signed-integer-truncation -fsanitize-trap=implicit-signed-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
7 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[INT:.*]] = {{.*}} c"'int'\00" }
8 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[UNSIGNED_SHORT:.*]] = {{.*}} c"'unsigned short'\00" }
9 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_100:.*]] = {{.*}}, i32 100, i32 11 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
10 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 11 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
11 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 10 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
12 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 10 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
13 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[SHORT:.*]] = {{.*}} c"'short'\00" }
14 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 11 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
15 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 11 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
16 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 10 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
17 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 10 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
19 unsigned short t0(unsigned short x) {
20 // CHECK-NOSANITIZE-LABEL: @t0(
21 // CHECK-NOSANITIZE-NEXT: entry:
22 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
23 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
24 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
25 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], 1
26 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
27 // CHECK-NOSANITIZE-NEXT: ret i16 [[X_RELOADED]]
29 // CHECK-SANITIZE-LABEL: @t0(
30 // CHECK-SANITIZE-NEXT: entry:
31 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
32 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
33 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
34 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = zext i16 [[X_RELOADED]] to i32
35 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], 1
36 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
37 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
38 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
39 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
40 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
41 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
42 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
43 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
44 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_100]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
45 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_100]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
46 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
47 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
48 // CHECK-SANITIZE: [[CONT]]:
49 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
50 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
51 #line 100
52 return x++;
54 unsigned short t1(unsigned short x) {
55 // CHECK-NOSANITIZE-LABEL: @t1(
56 // CHECK-NOSANITIZE-NEXT: entry:
57 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
58 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
59 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
60 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
61 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
62 // CHECK-NOSANITIZE-NEXT: ret i16 [[X_RELOADED]]
64 // CHECK-SANITIZE-LABEL: @t1(
65 // CHECK-SANITIZE-NEXT: entry:
66 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
67 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
68 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
69 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = zext i16 [[X_RELOADED]] to i32
70 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
71 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
72 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
73 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
74 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
75 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
76 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
77 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
78 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
79 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_200]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
80 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_200]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
81 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
82 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
83 // CHECK-SANITIZE: [[CONT]]:
84 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
85 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
86 #line 200
87 return x--;
90 unsigned short t2(unsigned short x) {
91 // CHECK-NOSANITIZE-LABEL: @t2(
92 // CHECK-NOSANITIZE-NEXT: entry:
93 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
94 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
95 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
96 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], 1
97 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
98 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
100 // CHECK-SANITIZE-LABEL: @t2(
101 // CHECK-SANITIZE-NEXT: entry:
102 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
103 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
104 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
105 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = zext i16 [[X_RELOADED]] to i32
106 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], 1
107 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
108 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
109 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
110 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
111 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
112 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
113 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
114 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
115 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_300]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
116 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_300]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
117 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
118 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
119 // CHECK-SANITIZE: [[CONT]]:
120 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
121 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
122 #line 300
123 return ++x;
126 unsigned short t3(unsigned short x) {
127 // CHECK-NOSANITIZE-LABEL: @t3(
128 // CHECK-NOSANITIZE-NEXT: entry:
129 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
130 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
131 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
132 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
133 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
134 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
136 // CHECK-SANITIZE-LABEL: @t3(
137 // CHECK-SANITIZE-NEXT: entry:
138 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
139 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
140 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
141 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = zext i16 [[X_RELOADED]] to i32
142 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
143 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
144 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
145 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
146 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
147 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
148 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
149 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
150 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
151 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_400]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
152 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_400]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
153 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
154 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
155 // CHECK-SANITIZE: [[CONT]]:
156 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
157 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
158 #line 400
159 return --x;
162 signed short t4(signed short x) {
163 // CHECK-NOSANITIZE-LABEL: @t4(
164 // CHECK-NOSANITIZE-NEXT: entry:
165 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
166 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
167 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
168 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], 1
169 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
170 // CHECK-NOSANITIZE-NEXT: ret i16 [[X_RELOADED]]
172 // CHECK-SANITIZE-LABEL: @t4(
173 // CHECK-SANITIZE-NEXT: entry:
174 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
175 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
176 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
177 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
178 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], 1
179 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
180 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = sext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
181 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
182 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
183 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
184 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
185 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
186 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
187 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_500]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
188 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_500]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
189 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
190 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
191 // CHECK-SANITIZE: [[CONT]]:
192 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
193 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
194 #line 500
195 return x++;
197 signed short t5(signed short x) {
198 // CHECK-NOSANITIZE-LABEL: @t5(
199 // CHECK-NOSANITIZE-NEXT: entry:
200 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
201 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
202 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
203 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
204 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
205 // CHECK-NOSANITIZE-NEXT: ret i16 [[X_RELOADED]]
207 // CHECK-SANITIZE-LABEL: @t5(
208 // CHECK-SANITIZE-NEXT: entry:
209 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
210 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
211 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
212 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
213 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
214 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
215 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = sext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
216 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
217 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
218 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
219 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
220 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
221 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
222 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_600]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
223 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_600]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
224 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
225 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
226 // CHECK-SANITIZE: [[CONT]]:
227 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
228 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
229 #line 600
230 return x--;
233 signed short t6(signed short x) {
234 // CHECK-NOSANITIZE-LABEL: @t6(
235 // CHECK-NOSANITIZE-NEXT: entry:
236 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
237 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
238 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
239 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], 1
240 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
241 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
243 // CHECK-SANITIZE-LABEL: @t6(
244 // CHECK-SANITIZE-NEXT: entry:
245 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
246 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
247 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
248 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
249 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], 1
250 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
251 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = sext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
252 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
253 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
254 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
255 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
256 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
257 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
258 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_700]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
259 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_700]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
260 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
261 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
262 // CHECK-SANITIZE: [[CONT]]:
263 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
264 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
265 #line 700
266 return ++x;
269 signed short t7(signed short x) {
270 // CHECK-NOSANITIZE-LABEL: @t7(
271 // CHECK-NOSANITIZE-NEXT: entry:
272 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
273 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
274 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
275 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
276 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
277 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
279 // CHECK-SANITIZE-LABEL: @t7(
280 // CHECK-SANITIZE-NEXT: entry:
281 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
282 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
283 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
284 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
285 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
286 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
287 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED_PROMOTED:%.*]] = sext i16 [[X_PROMOTED_DEMOTED]] to i32, !nosanitize
288 // CHECK-SANITIZE-NEXT: [[TRUNCHECK:%.*]] = icmp eq i32 [[X_PROMOTED_DEMOTED_PROMOTED]], [[INC]], !nosanitize
289 // CHECK-SANITIZE-NEXT: br i1 [[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
290 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
291 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
292 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
293 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
294 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_800]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
295 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_800]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
296 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
297 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
298 // CHECK-SANITIZE: [[CONT]]:
299 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
300 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
301 #line 800
302 return --x;