1
1
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2
- // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s
3
- // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=TR
4
- // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s --check-prefixes=REC
2
+ // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks | FileCheck %s
3
+ // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null,local-bounds | FileCheck %s --check-prefixes=TR
4
+ // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null,local-bounds -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null,local-bounds | FileCheck %s --check-prefixes=REC
5
5
6
6
7
7
// CHECK-LABEL: define dso_local noundef i32 @div(
18
18
// CHECK: [[HANDLER_DIVREM_OVERFLOW]]:
19
19
// CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
20
20
// CHECK-NEXT: [[TMP5:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
21
- // CHECK-NEXT: tail call void @__ubsan_handle_divrem_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4 :[0-9]+]], !nosanitize [[META2]]
21
+ // CHECK-NEXT: tail call void @__ubsan_handle_divrem_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6 :[0-9]+]], !nosanitize [[META2]]
22
22
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
23
23
// CHECK: [[CONT]]:
24
24
// CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
36
36
// TR-NEXT: [[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]]
37
37
// TR-NEXT: br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
38
38
// TR: [[TRAP]]:
39
- // TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR4 :[0-9]+]], !nosanitize [[META2]]
39
+ // TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR5 :[0-9]+]], !nosanitize [[META2]]
40
40
// TR-NEXT: unreachable, !nosanitize [[META2]]
41
41
// TR: [[CONT]]:
42
42
// TR-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
56
56
// REC: [[HANDLER_DIVREM_OVERFLOW]]:
57
57
// REC-NEXT: [[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
58
58
// REC-NEXT: [[TMP5:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
59
- // REC-NEXT: tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4 :[0-9]+]], !nosanitize [[META2]]
59
+ // REC-NEXT: tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6 :[0-9]+]], !nosanitize [[META2]]
60
60
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
61
61
// REC: [[CONT]]:
62
62
// REC-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -74,7 +74,7 @@ int div(int x, int y) {
74
74
// CHECK-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
75
75
// CHECK-NEXT: br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], label %[[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
76
76
// CHECK: [[HANDLER_TYPE_MISMATCH]]:
77
- // CHECK-NEXT: tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR4 ]], !nosanitize [[META2]]
77
+ // CHECK-NEXT: tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6 ]], !nosanitize [[META2]]
78
78
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
79
79
// CHECK: [[CONT]]:
80
80
// CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
@@ -88,7 +88,7 @@ int div(int x, int y) {
88
88
// TR-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
89
89
// TR-NEXT: br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
90
90
// TR: [[TRAP]]:
91
- // TR-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR4 ]], !nosanitize [[META2]]
91
+ // TR-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR5 ]], !nosanitize [[META2]]
92
92
// TR-NEXT: unreachable, !nosanitize [[META2]]
93
93
// TR: [[CONT]]:
94
94
// TR-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA3:![0-9]+]]
@@ -102,7 +102,7 @@ int div(int x, int y) {
102
102
// REC-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
103
103
// REC-NEXT: br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], label %[[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
104
104
// REC: [[HANDLER_TYPE_MISMATCH]]:
105
- // REC-NEXT: tail call void @__ubsan_handle_type_mismatch_v1(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR4 ]], !nosanitize [[META2]]
105
+ // REC-NEXT: tail call void @__ubsan_handle_type_mismatch_v1(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6 ]], !nosanitize [[META2]]
106
106
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
107
107
// REC: [[CONT]]:
108
108
// REC-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
@@ -123,7 +123,7 @@ int null(int* x) {
123
123
// CHECK: [[HANDLER_ADD_OVERFLOW]]:
124
124
// CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
125
125
// CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
126
- // CHECK-NEXT: tail call void @__ubsan_handle_add_overflow_abort(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4 ]], !nosanitize [[META2]]
126
+ // CHECK-NEXT: tail call void @__ubsan_handle_add_overflow_abort(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR6 ]], !nosanitize [[META2]]
127
127
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
128
128
// CHECK: [[CONT]]:
129
129
// CHECK-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -138,7 +138,7 @@ int null(int* x) {
138
138
// TR-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
139
139
// TR-NEXT: br i1 [[DOTDEMORGAN]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
140
140
// TR: [[TRAP]]:
141
- // TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4 ]], !nosanitize [[META2]]
141
+ // TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR5 ]], !nosanitize [[META2]]
142
142
// TR-NEXT: unreachable, !nosanitize [[META2]]
143
143
// TR: [[CONT]]:
144
144
// TR-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -155,7 +155,7 @@ int null(int* x) {
155
155
// REC: [[HANDLER_ADD_OVERFLOW]]:
156
156
// REC-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
157
157
// REC-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
158
- // REC-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4 ]], !nosanitize [[META2]]
158
+ // REC-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR6 ]], !nosanitize [[META2]]
159
159
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
160
160
// REC: [[CONT]]:
161
161
// REC-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -164,24 +164,90 @@ int null(int* x) {
164
164
int overflow (int x , int y ) {
165
165
return x + y ;
166
166
}
167
+
168
+ void use (double * );
169
+
170
+ // CHECK-LABEL: define dso_local double @lbounds(
171
+ // CHECK-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
172
+ // CHECK-NEXT: [[ENTRY:.*:]]
173
+ // CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
174
+ // CHECK-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
175
+ // CHECK-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR7:[0-9]+]]
176
+ // CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
177
+ // CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
178
+ // CHECK-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
179
+ // CHECK: [[BB1]]:
180
+ // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[VLA]], i64 [[IDXPROM]]
181
+ // CHECK-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]]
182
+ // CHECK-NEXT: ret double [[TMP2]]
183
+ // CHECK: [[TRAP]]:
184
+ // CHECK-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR6]]
185
+ // CHECK-NEXT: unreachable
186
+ //
187
+ // TR-LABEL: define dso_local double @lbounds(
188
+ // TR-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
189
+ // TR-NEXT: [[ENTRY:.*:]]
190
+ // TR-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
191
+ // TR-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
192
+ // TR-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR6:[0-9]+]]
193
+ // TR-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
194
+ // TR-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
195
+ // TR-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
196
+ // TR: [[BB1]]:
197
+ // TR-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[VLA]], i64 [[IDXPROM]]
198
+ // TR-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA7:![0-9]+]]
199
+ // TR-NEXT: ret double [[TMP2]]
200
+ // TR: [[TRAP]]:
201
+ // TR-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR5]]
202
+ // TR-NEXT: unreachable
203
+ //
204
+ // REC-LABEL: define dso_local double @lbounds(
205
+ // REC-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
206
+ // REC-NEXT: [[ENTRY:.*:]]
207
+ // REC-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
208
+ // REC-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
209
+ // REC-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR5:[0-9]+]]
210
+ // REC-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
211
+ // REC-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
212
+ // REC-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
213
+ // REC: [[BB1]]:
214
+ // REC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[VLA]], i64 [[IDXPROM]]
215
+ // REC-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]]
216
+ // REC-NEXT: ret double [[TMP2]]
217
+ // REC: [[TRAP]]:
218
+ // REC-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR6]]
219
+ // REC-NEXT: br label %[[BB1]]
220
+ //
221
+ double lbounds (int b , int i ) {
222
+ double a [b ];
223
+ use (a );
224
+ return a [i ];
225
+ }
226
+
167
227
//.
168
228
// CHECK: [[META2]] = !{}
169
229
// CHECK: [[PROF3]] = !{!"branch_weights", i32 1, i32 1048575}
170
230
// CHECK: [[TBAA4]] = !{[[META5:![0-9]+]], [[META5]], i64 0}
171
231
// CHECK: [[META5]] = !{!"int", [[META6:![0-9]+]], i64 0}
172
232
// CHECK: [[META6]] = !{!"omnipotent char", [[META7:![0-9]+]], i64 0}
173
233
// CHECK: [[META7]] = !{!"Simple C/C++ TBAA"}
234
+ // CHECK: [[TBAA8]] = !{[[META9:![0-9]+]], [[META9]], i64 0}
235
+ // CHECK: [[META9]] = !{!"double", [[META6]], i64 0}
174
236
//.
175
237
// TR: [[META2]] = !{}
176
238
// TR: [[TBAA3]] = !{[[META4:![0-9]+]], [[META4]], i64 0}
177
239
// TR: [[META4]] = !{!"int", [[META5:![0-9]+]], i64 0}
178
240
// TR: [[META5]] = !{!"omnipotent char", [[META6:![0-9]+]], i64 0}
179
241
// TR: [[META6]] = !{!"Simple C/C++ TBAA"}
242
+ // TR: [[TBAA7]] = !{[[META8:![0-9]+]], [[META8]], i64 0}
243
+ // TR: [[META8]] = !{!"double", [[META5]], i64 0}
180
244
//.
181
245
// REC: [[META2]] = !{}
182
246
// REC: [[PROF3]] = !{!"branch_weights", i32 1, i32 1048575}
183
247
// REC: [[TBAA4]] = !{[[META5:![0-9]+]], [[META5]], i64 0}
184
248
// REC: [[META5]] = !{!"int", [[META6:![0-9]+]], i64 0}
185
249
// REC: [[META6]] = !{!"omnipotent char", [[META7:![0-9]+]], i64 0}
186
250
// REC: [[META7]] = !{!"Simple C/C++ TBAA"}
251
+ // REC: [[TBAA8]] = !{[[META9:![0-9]+]], [[META9]], i64 0}
252
+ // REC: [[META9]] = !{!"double", [[META6]], i64 0}
187
253
//.
0 commit comments