Skip to content

Commit 60693f2

Browse files
committed
return null
Created using spr 1.3.4
1 parent 523708e commit 60693f2

File tree

1 file changed

+48
-24
lines changed

1 file changed

+48
-24
lines changed

clang/test/CodeGen/allow-ubsan-check.c

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// 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,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,local-bounds -mllvm -ubsan-guard-checks -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,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,local-bounds -mllvm -ubsan-guard-checks -fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,local-bounds | 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
55

66

77
// CHECK-LABEL: define dso_local noundef i32 @div(
@@ -18,7 +18,7 @@
1818
// CHECK: [[HANDLER_DIVREM_OVERFLOW]]:
1919
// CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
2020
// 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]]) #[[ATTR7:[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]]
2222
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
2323
// CHECK: [[CONT]]:
2424
// CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -36,7 +36,7 @@
3636
// TR-NEXT: [[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]]
3737
// TR-NEXT: br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
3838
// TR: [[TRAP]]:
39-
// TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR6:[0-9]+]], !nosanitize [[META2]]
39+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR5:[0-9]+]], !nosanitize [[META2]]
4040
// TR-NEXT: unreachable, !nosanitize [[META2]]
4141
// TR: [[CONT]]:
4242
// TR-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -56,7 +56,7 @@
5656
// REC: [[HANDLER_DIVREM_OVERFLOW]]:
5757
// REC-NEXT: [[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
5858
// 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]]) #[[ATTR7:[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]]
6060
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
6161
// REC: [[CONT]]:
6262
// REC-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -67,22 +67,46 @@ int div(int x, int y) {
6767
}
6868

6969
// CHECK-LABEL: define dso_local i32 @null(
70-
// CHECK-SAME: ptr nocapture noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
70+
// CHECK-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
7171
// CHECK-NEXT: [[ENTRY:.*:]]
72-
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
73-
// CHECK-NEXT: ret i32 [[TMP0]]
72+
// CHECK-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
73+
// CHECK-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
74+
// CHECK-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
75+
// CHECK-NEXT: br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], label %[[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
76+
// CHECK: [[HANDLER_TYPE_MISMATCH]]:
77+
// CHECK-NEXT: tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6]], !nosanitize [[META2]]
78+
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
79+
// CHECK: [[CONT]]:
80+
// CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
81+
// CHECK-NEXT: ret i32 [[TMP2]]
7482
//
7583
// TR-LABEL: define dso_local i32 @null(
76-
// TR-SAME: ptr nocapture noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
84+
// TR-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
7785
// TR-NEXT: [[ENTRY:.*:]]
78-
// TR-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA3:![0-9]+]]
79-
// TR-NEXT: ret i32 [[TMP0]]
86+
// TR-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
87+
// TR-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
88+
// TR-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
89+
// TR-NEXT: br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
90+
// TR: [[TRAP]]:
91+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR5]], !nosanitize [[META2]]
92+
// TR-NEXT: unreachable, !nosanitize [[META2]]
93+
// TR: [[CONT]]:
94+
// TR-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA3:![0-9]+]]
95+
// TR-NEXT: ret i32 [[TMP2]]
8096
//
8197
// REC-LABEL: define dso_local i32 @null(
82-
// REC-SAME: ptr nocapture noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
98+
// REC-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
8399
// REC-NEXT: [[ENTRY:.*:]]
84-
// REC-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
85-
// REC-NEXT: ret i32 [[TMP0]]
100+
// REC-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
101+
// REC-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
102+
// REC-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
103+
// REC-NEXT: br i1 [[DOTNOT1]], label %[[HANDLER_TYPE_MISMATCH:.*]], label %[[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
104+
// REC: [[HANDLER_TYPE_MISMATCH]]:
105+
// REC-NEXT: tail call void @__ubsan_handle_type_mismatch_v1(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR6]], !nosanitize [[META2]]
106+
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
107+
// REC: [[CONT]]:
108+
// REC-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
109+
// REC-NEXT: ret i32 [[TMP2]]
86110
//
87111
int null(int* x) {
88112
return *x;
@@ -99,7 +123,7 @@ int null(int* x) {
99123
// CHECK: [[HANDLER_ADD_OVERFLOW]]:
100124
// CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
101125
// CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
102-
// CHECK-NEXT: tail call void @__ubsan_handle_add_overflow_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR7]], !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]]
103127
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
104128
// CHECK: [[CONT]]:
105129
// CHECK-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -114,7 +138,7 @@ int null(int* x) {
114138
// TR-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
115139
// TR-NEXT: br i1 [[DOTDEMORGAN]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
116140
// TR: [[TRAP]]:
117-
// TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR6]], !nosanitize [[META2]]
141+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR5]], !nosanitize [[META2]]
118142
// TR-NEXT: unreachable, !nosanitize [[META2]]
119143
// TR: [[CONT]]:
120144
// TR-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -131,7 +155,7 @@ int null(int* x) {
131155
// REC: [[HANDLER_ADD_OVERFLOW]]:
132156
// REC-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
133157
// REC-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
134-
// REC-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB2:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR7]], !nosanitize [[META2]]
158+
// REC-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR6]], !nosanitize [[META2]]
135159
// REC-NEXT: br label %[[CONT]], !nosanitize [[META2]]
136160
// REC: [[CONT]]:
137161
// REC-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -148,7 +172,7 @@ void use(double*);
148172
// CHECK-NEXT: [[ENTRY:.*:]]
149173
// CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
150174
// CHECK-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
151-
// CHECK-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR8:[0-9]+]]
175+
// CHECK-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR7:[0-9]+]]
152176
// CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
153177
// CHECK-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
154178
// CHECK-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
@@ -157,15 +181,15 @@ void use(double*);
157181
// CHECK-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]]
158182
// CHECK-NEXT: ret double [[TMP2]]
159183
// CHECK: [[TRAP]]:
160-
// CHECK-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR7]]
184+
// CHECK-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR6]]
161185
// CHECK-NEXT: unreachable
162186
//
163187
// TR-LABEL: define dso_local double @lbounds(
164188
// TR-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
165189
// TR-NEXT: [[ENTRY:.*:]]
166190
// TR-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
167191
// TR-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
168-
// TR-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR7:[0-9]+]]
192+
// TR-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR6:[0-9]+]]
169193
// TR-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
170194
// TR-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
171195
// TR-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
@@ -174,15 +198,15 @@ void use(double*);
174198
// TR-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA7:![0-9]+]]
175199
// TR-NEXT: ret double [[TMP2]]
176200
// TR: [[TRAP]]:
177-
// TR-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR6]]
201+
// TR-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR5]]
178202
// TR-NEXT: unreachable
179203
//
180204
// REC-LABEL: define dso_local double @lbounds(
181205
// REC-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
182206
// REC-NEXT: [[ENTRY:.*:]]
183207
// REC-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
184208
// REC-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
185-
// REC-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR6:[0-9]+]]
209+
// REC-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR5:[0-9]+]]
186210
// REC-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
187211
// REC-NEXT: [[DOTNOT:%.*]] = icmp ugt i64 [[TMP0]], [[IDXPROM]]
188212
// REC-NEXT: br i1 [[DOTNOT]], label %[[BB1:.*]], label %[[TRAP:.*]]
@@ -191,7 +215,7 @@ void use(double*);
191215
// REC-NEXT: [[TMP2:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]]
192216
// REC-NEXT: ret double [[TMP2]]
193217
// REC: [[TRAP]]:
194-
// REC-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR7]]
218+
// REC-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR6]]
195219
// REC-NEXT: br label %[[BB1]]
196220
//
197221
double lbounds(int b, int i) {

0 commit comments

Comments
 (0)