[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / catch-implicit-integer-sign-changes-incdec.c
blob0de45720e95606a71b98af3054ac20d582975f51
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-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -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-integer-sign-change -fsanitize-recover=implicit-integer-sign-change -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-integer-sign-change -fsanitize-trap=implicit-integer-sign-change -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 3 }
10 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 11 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 3 }
11 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 10 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 3 }
12 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 10 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 3 }
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 3 }
15 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 11 }, ptr @[[INT]], ptr @[[SHORT]], i8 3 }
16 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 10 }, ptr @[[INT]], ptr @[[SHORT]], i8 3 }
17 // CHECK-SANITIZE-ANYRECOVER-DAG: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 10 }, ptr @[[INT]], ptr @[[SHORT]], i8 3 }
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: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
38 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], false, !nosanitize
39 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], 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: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
73 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], false, !nosanitize
74 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], 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: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
109 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], false, !nosanitize
110 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], 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: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
145 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], false, !nosanitize
146 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], 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: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
181 // CHECK-SANITIZE-NEXT: [[DST_NEGATIVITYCHECK:%.*]] = icmp slt i16 [[X_PROMOTED_DEMOTED]], 0, !nosanitize !2
182 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], [[DST_NEGATIVITYCHECK]], !nosanitize
183 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
184 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
185 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
186 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
187 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
188 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_500]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
189 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_500]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
190 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
191 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
192 // CHECK-SANITIZE: [[CONT]]:
193 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
194 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
195 #line 500
196 return x++;
198 signed short t5(signed short x) {
199 // CHECK-NOSANITIZE-LABEL: @t5(
200 // CHECK-NOSANITIZE-NEXT: entry:
201 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
202 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
203 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
204 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
205 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
206 // CHECK-NOSANITIZE-NEXT: ret i16 [[X_RELOADED]]
208 // CHECK-SANITIZE-LABEL: @t5(
209 // CHECK-SANITIZE-NEXT: entry:
210 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
211 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
212 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
213 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
214 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
215 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
216 // CHECK-SANITIZE-NEXT: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
217 // CHECK-SANITIZE-NEXT: [[DST_NEGATIVITYCHECK:%.*]] = icmp slt i16 [[X_PROMOTED_DEMOTED]], 0, !nosanitize !2
218 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], [[DST_NEGATIVITYCHECK]], !nosanitize
219 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
220 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
221 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
222 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
223 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
224 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_600]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
225 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_600]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
226 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
227 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
228 // CHECK-SANITIZE: [[CONT]]:
229 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
230 // CHECK-SANITIZE-NEXT: ret i16 [[X_RELOADED]]
231 #line 600
232 return x--;
235 signed short t6(signed short x) {
236 // CHECK-NOSANITIZE-LABEL: @t6(
237 // CHECK-NOSANITIZE-NEXT: entry:
238 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
239 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
240 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
241 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], 1
242 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
243 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
245 // CHECK-SANITIZE-LABEL: @t6(
246 // CHECK-SANITIZE-NEXT: entry:
247 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
248 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
249 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
250 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
251 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], 1
252 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
253 // CHECK-SANITIZE-NEXT: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
254 // CHECK-SANITIZE-NEXT: [[DST_NEGATIVITYCHECK:%.*]] = icmp slt i16 [[X_PROMOTED_DEMOTED]], 0, !nosanitize !2
255 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], [[DST_NEGATIVITYCHECK]], !nosanitize
256 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
257 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
258 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
259 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
260 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
261 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_700]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
262 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_700]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
263 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
264 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
265 // CHECK-SANITIZE: [[CONT]]:
266 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
267 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
268 #line 700
269 return ++x;
272 signed short t7(signed short x) {
273 // CHECK-NOSANITIZE-LABEL: @t7(
274 // CHECK-NOSANITIZE-NEXT: entry:
275 // CHECK-NOSANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
276 // CHECK-NOSANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
277 // CHECK-NOSANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
278 // CHECK-NOSANITIZE-NEXT: [[INC:%.*]] = add i16 [[X_RELOADED]], -1
279 // CHECK-NOSANITIZE-NEXT: store i16 [[INC]], ptr [[X_ADDR]], align 2
280 // CHECK-NOSANITIZE-NEXT: ret i16 [[INC]]
282 // CHECK-SANITIZE-LABEL: @t7(
283 // CHECK-SANITIZE-NEXT: entry:
284 // CHECK-SANITIZE-NEXT: [[X_ADDR:%.*]] = alloca i16, align 2
285 // CHECK-SANITIZE-NEXT: store i16 [[X:%.*]], ptr [[X_ADDR]], align 2
286 // CHECK-SANITIZE-NEXT: [[X_RELOADED:%.*]] = load i16, ptr [[X_ADDR]], align 2
287 // CHECK-SANITIZE-NEXT: [[X_PROMOTED:%.*]] = sext i16 [[X_RELOADED]] to i32
288 // CHECK-SANITIZE-NEXT: [[INC:%.*]] = add i32 [[X_PROMOTED]], -1
289 // CHECK-SANITIZE-NEXT: [[X_PROMOTED_DEMOTED:%.*]] = trunc i32 [[INC]] to i16
290 // CHECK-SANITIZE-NEXT: [[SRC_INC_NEGATIVITYCHECK:%.*]] = icmp slt i32 [[INC]], 0, !nosanitize !2
291 // CHECK-SANITIZE-NEXT: [[DST_NEGATIVITYCHECK:%.*]] = icmp slt i16 [[X_PROMOTED_DEMOTED]], 0, !nosanitize !2
292 // CHECK-SANITIZE-NEXT: [[SIGNCHANGECHECK:%.*]] = icmp eq i1 [[SRC_INC_NEGATIVITYCHECK]], [[DST_NEGATIVITYCHECK]], !nosanitize
293 // CHECK-SANITIZE-NEXT: br i1 [[SIGNCHANGECHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_X_PROMOTEDERSION:[^,]+]],{{.*}} !nosanitize
294 // CHECK-SANITIZE: [[HANDLER_IMPLICIT_X_PROMOTEDERSION]]:
295 // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.ubsantrap(i8 7){{.*}}, !nosanitize
296 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP1:%.*]] = zext i32 [[INC]] to i64, !nosanitize
297 // CHECK-SANITIZE-ANYRECOVER-NEXT: [[TMP2:%.*]] = zext i16 [[X_PROMOTED_DEMOTED]] to i64, !nosanitize
298 // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(ptr @[[LINE_800]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
299 // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_800]], i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
300 // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
301 // CHECK-SANITIZE-RECOVER-NEXT: br label %[[CONT]], !nosanitize
302 // CHECK-SANITIZE: [[CONT]]:
303 // CHECK-SANITIZE-NEXT: store i16 [[X_PROMOTED_DEMOTED]], ptr [[X_ADDR]], align 2
304 // CHECK-SANITIZE-NEXT: ret i16 [[X_PROMOTED_DEMOTED]]
305 #line 800
306 return --x;