1- // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
1+ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
22// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero,null -mllvm -ubsan-guard-checks | FileCheck %s
33// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -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=TRAP
44// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O3 -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=RECOVER
55
66
77// CHECK-LABEL: define dso_local noundef i32 @div(
88// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
9- // CHECK-NEXT: entry:
9+ // CHECK-NEXT: [[ENTRY:.*:]]
1010// CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]]
1111// CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]]
1212// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]]
1313// CHECK-NEXT: [[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]]
1414// CHECK-NEXT: [[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]]
1515// CHECK-NEXT: [[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]]
1616// CHECK-NEXT: [[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]]
17- // CHECK-NEXT: br i1 [[DOTNOT1]], label [[HANDLER_DIVREM_OVERFLOW:% .*]], label [[CONT:% .*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
18- // CHECK: handler.divrem_overflow :
17+ // CHECK-NEXT: br i1 [[DOTNOT1]], label % [[HANDLER_DIVREM_OVERFLOW:.*]], label % [[CONT:.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
18+ // 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]]
2121// CHECK-NEXT: tail call void @__ubsan_handle_divrem_overflow_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]]
2222// CHECK-NEXT: unreachable, !nosanitize [[META2]]
23- // CHECK: cont :
23+ // CHECK: [[CONT]] :
2424// CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
2525// CHECK-NEXT: ret i32 [[DIV]]
2626//
2727// TRAP-LABEL: define dso_local noundef i32 @div(
2828// TRAP-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
29- // TRAP-NEXT: entry:
29+ // TRAP-NEXT: [[ENTRY:.*:]]
3030// TRAP-NEXT: [[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]]
3131// TRAP-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]]
3232// TRAP-NEXT: [[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]]
3333// TRAP-NEXT: [[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]]
3434// TRAP-NEXT: [[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]]
3535// TRAP-NEXT: [[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]]
3636// TRAP-NEXT: [[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]]
37- // TRAP-NEXT: br i1 [[DOTNOT1]], label [[TRAP:% .*]], label [[CONT:% .*]], !nosanitize [[META2]]
38- // TRAP: trap :
37+ // TRAP-NEXT: br i1 [[DOTNOT1]], label % [[TRAP:.*]], label % [[CONT:.*]], !nosanitize [[META2]]
38+ // TRAP: [[TRAP]] :
3939// TRAP-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR4:[0-9]+]], !nosanitize [[META2]]
4040// TRAP-NEXT: unreachable, !nosanitize [[META2]]
41- // TRAP: cont :
41+ // TRAP: [[CONT]] :
4242// TRAP-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
4343// TRAP-NEXT: ret i32 [[DIV]]
4444//
4545// RECOVER-LABEL: define dso_local noundef i32 @div(
4646// RECOVER-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
47- // RECOVER-NEXT: entry:
47+ // RECOVER-NEXT: [[ENTRY:.*:]]
4848// RECOVER-NEXT: [[TMP0:%.*]] = icmp eq i32 [[Y]], 0, !nosanitize [[META2:![0-9]+]]
4949// RECOVER-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X]], -2147483648, !nosanitize [[META2]]
5050// RECOVER-NEXT: [[TMP2:%.*]] = icmp eq i32 [[Y]], -1, !nosanitize [[META2]]
5151// RECOVER-NEXT: [[OR_NOT5:%.*]] = and i1 [[TMP1]], [[TMP2]]
5252// RECOVER-NEXT: [[DOTNOT3:%.*]] = or i1 [[TMP0]], [[OR_NOT5]]
5353// RECOVER-NEXT: [[TMP3:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META2]]
5454// RECOVER-NEXT: [[DOTNOT1:%.*]] = and i1 [[DOTNOT3]], [[TMP3]]
55- // RECOVER-NEXT: br i1 [[DOTNOT1]], label [[HANDLER_DIVREM_OVERFLOW:% .*]], label [[CONT:% .*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
56- // RECOVER: handler.divrem_overflow :
55+ // RECOVER-NEXT: br i1 [[DOTNOT1]], label % [[HANDLER_DIVREM_OVERFLOW:.*]], label % [[CONT:.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
56+ // RECOVER: [[HANDLER_DIVREM_OVERFLOW]] :
5757// RECOVER-NEXT: [[TMP4:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
5858// RECOVER-NEXT: [[TMP5:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
5959// RECOVER-NEXT: tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @[[GLOB1:[0-9]+]], i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META2]]
60- // RECOVER-NEXT: br label [[CONT]], !nosanitize [[META2]]
61- // RECOVER: cont :
60+ // RECOVER-NEXT: br label % [[CONT]], !nosanitize [[META2]]
61+ // RECOVER: [[CONT]] :
6262// RECOVER-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
6363// RECOVER-NEXT: ret i32 [[DIV]]
6464//
@@ -68,43 +68,43 @@ int div(int x, int y) {
6868
6969// CHECK-LABEL: define dso_local i32 @null(
7070// CHECK-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
71- // CHECK-NEXT: entry:
71+ // CHECK-NEXT: [[ENTRY:.*:]]
7272// CHECK-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
7373// CHECK-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
7474// 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 :
75+ // CHECK-NEXT: br i1 [[DOTNOT1]], label % [[HANDLER_TYPE_MISMATCH:.*]], label % [[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
76+ // CHECK: [[HANDLER_TYPE_MISMATCH]] :
7777// CHECK-NEXT: tail call void @__ubsan_handle_type_mismatch_v1_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR4]], !nosanitize [[META2]]
7878// CHECK-NEXT: unreachable, !nosanitize [[META2]]
79- // CHECK: cont :
79+ // CHECK: [[CONT]] :
8080// CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
8181// CHECK-NEXT: ret i32 [[TMP2]]
8282//
8383// TRAP-LABEL: define dso_local i32 @null(
8484// TRAP-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
85- // TRAP-NEXT: entry:
85+ // TRAP-NEXT: [[ENTRY:.*:]]
8686// TRAP-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
8787// TRAP-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
8888// TRAP-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
89- // TRAP-NEXT: br i1 [[DOTNOT1]], label [[TRAP:% .*]], label [[CONT:% .*]], !nosanitize [[META2]]
90- // TRAP: trap :
89+ // TRAP-NEXT: br i1 [[DOTNOT1]], label % [[TRAP:.*]], label % [[CONT:.*]], !nosanitize [[META2]]
90+ // TRAP: [[TRAP]] :
9191// TRAP-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR4]], !nosanitize [[META2]]
9292// TRAP-NEXT: unreachable, !nosanitize [[META2]]
93- // TRAP: cont :
93+ // TRAP: [[CONT]] :
9494// TRAP-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA3:![0-9]+]]
9595// TRAP-NEXT: ret i32 [[TMP2]]
9696//
9797// RECOVER-LABEL: define dso_local i32 @null(
9898// RECOVER-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
99- // RECOVER-NEXT: entry:
99+ // RECOVER-NEXT: [[ENTRY:.*:]]
100100// RECOVER-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
101101// RECOVER-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 22), !nosanitize [[META2]]
102102// RECOVER-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
103- // RECOVER-NEXT: br i1 [[DOTNOT1]], label [[HANDLER_TYPE_MISMATCH:% .*]], label [[CONT:% .*]], !prof [[PROF3]], !nosanitize [[META2]]
104- // RECOVER: handler.type_mismatch :
103+ // RECOVER-NEXT: br i1 [[DOTNOT1]], label % [[HANDLER_TYPE_MISMATCH:.*]], label % [[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
104+ // RECOVER: [[HANDLER_TYPE_MISMATCH]] :
105105// RECOVER-NEXT: tail call void @__ubsan_handle_type_mismatch_v1(ptr nonnull @[[GLOB2:[0-9]+]], i64 0) #[[ATTR4]], !nosanitize [[META2]]
106- // RECOVER-NEXT: br label [[CONT]], !nosanitize [[META2]]
107- // RECOVER: cont :
106+ // RECOVER-NEXT: br label % [[CONT]], !nosanitize [[META2]]
107+ // RECOVER: [[CONT]] :
108108// RECOVER-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA4:![0-9]+]]
109109// RECOVER-NEXT: ret i32 [[TMP2]]
110110//
@@ -114,50 +114,50 @@ int null(int* x) {
114114
115115// CHECK-LABEL: define dso_local noundef i32 @overflow(
116116// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
117- // CHECK-NEXT: entry:
117+ // CHECK-NEXT: [[ENTRY:.*:]]
118118// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X]], i32 [[Y]]), !nosanitize [[META2]]
119119// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
120120// CHECK-NEXT: [[TMP2:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 0), !nosanitize [[META2]]
121121// CHECK-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
122- // CHECK-NEXT: br i1 [[DOTDEMORGAN]], label [[HANDLER_ADD_OVERFLOW:% .*]], label [[CONT:% .*]], !prof [[PROF3]], !nosanitize [[META2]]
123- // CHECK: handler.add_overflow :
122+ // CHECK-NEXT: br i1 [[DOTDEMORGAN]], label % [[HANDLER_ADD_OVERFLOW:.*]], label % [[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
123+ // CHECK: [[HANDLER_ADD_OVERFLOW]] :
124124// CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
125125// CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
126126// CHECK-NEXT: tail call void @__ubsan_handle_add_overflow_abort(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META2]]
127127// CHECK-NEXT: unreachable, !nosanitize [[META2]]
128- // CHECK: cont :
128+ // CHECK: [[CONT]] :
129129// CHECK-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
130130// CHECK-NEXT: ret i32 [[TMP5]]
131131//
132132// TRAP-LABEL: define dso_local noundef i32 @overflow(
133133// TRAP-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
134- // TRAP-NEXT: entry:
134+ // TRAP-NEXT: [[ENTRY:.*:]]
135135// TRAP-NEXT: [[TMP0:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X]], i32 [[Y]]), !nosanitize [[META2]]
136136// TRAP-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
137137// TRAP-NEXT: [[TMP2:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 0), !nosanitize [[META2]]
138138// TRAP-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
139- // TRAP-NEXT: br i1 [[DOTDEMORGAN]], label [[TRAP:% .*]], label [[CONT:% .*]], !nosanitize [[META2]]
140- // TRAP: trap :
139+ // TRAP-NEXT: br i1 [[DOTDEMORGAN]], label % [[TRAP:.*]], label % [[CONT:.*]], !nosanitize [[META2]]
140+ // TRAP: [[TRAP]] :
141141// TRAP-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
142142// TRAP-NEXT: unreachable, !nosanitize [[META2]]
143- // TRAP: cont :
143+ // TRAP: [[CONT]] :
144144// TRAP-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
145145// TRAP-NEXT: ret i32 [[TMP3]]
146146//
147147// RECOVER-LABEL: define dso_local noundef i32 @overflow(
148148// RECOVER-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
149- // RECOVER-NEXT: entry:
149+ // RECOVER-NEXT: [[ENTRY:.*:]]
150150// RECOVER-NEXT: [[TMP0:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X]], i32 [[Y]]), !nosanitize [[META2]]
151151// RECOVER-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
152152// RECOVER-NEXT: [[TMP2:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 0), !nosanitize [[META2]]
153153// RECOVER-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
154- // RECOVER-NEXT: br i1 [[DOTDEMORGAN]], label [[HANDLER_ADD_OVERFLOW:% .*]], label [[CONT:% .*]], !prof [[PROF3]], !nosanitize [[META2]]
155- // RECOVER: handler.add_overflow :
154+ // RECOVER-NEXT: br i1 [[DOTDEMORGAN]], label % [[HANDLER_ADD_OVERFLOW:.*]], label % [[CONT:.*]], !prof [[PROF3]], !nosanitize [[META2]]
155+ // RECOVER: [[HANDLER_ADD_OVERFLOW]] :
156156// RECOVER-NEXT: [[TMP3:%.*]] = zext i32 [[X]] to i64, !nosanitize [[META2]]
157157// RECOVER-NEXT: [[TMP4:%.*]] = zext i32 [[Y]] to i64, !nosanitize [[META2]]
158158// RECOVER-NEXT: tail call void @__ubsan_handle_add_overflow(ptr nonnull @[[GLOB3:[0-9]+]], i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META2]]
159- // RECOVER-NEXT: br label [[CONT]], !nosanitize [[META2]]
160- // RECOVER: cont :
159+ // RECOVER-NEXT: br label % [[CONT]], !nosanitize [[META2]]
160+ // RECOVER: [[CONT]] :
161161// RECOVER-NEXT: [[TMP5:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
162162// RECOVER-NEXT: ret i32 [[TMP5]]
163163//
0 commit comments