Skip to content

Commit aaa6fc7

Browse files
thurstondaokblast
authored andcommitted
[ubsan][test] Add allow-ubsan-check-divergence.c (llvm#164673)
This testcase shows that adding a ubsan check and then removing it during the LowerAllowCheck pass does not entirely undo the effects of adding the check.
1 parent cf619e5 commit aaa6fc7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
2+
3+
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
4+
// RUN: | FileCheck %s --check-prefixes=CLEAN-O1
5+
6+
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
7+
// RUN: -fsanitize=signed-integer-overflow \
8+
// RUN: -fsanitize-skip-hot-cutoff=signed-integer-overflow=1.0 \
9+
// RUN: -fallow-runtime-check-skip-hot-cutoff=1.0 \
10+
// RUN: | FileCheck %s --check-prefixes=UBSAN-O1
11+
12+
// This test shows that -fsanitize-skip-hot-cutoff=...=1.0 plus
13+
// -fallow-runtime-check-skip-hot-cutoff=1.0 does not perfectly undo the
14+
// effects of -fsanitize.
15+
16+
// CLEAN-O1-LABEL: define dso_local i32 @overflow(
17+
// CLEAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
18+
// CLEAN-O1-NEXT: [[ENTRY:.*:]]
19+
// CLEAN-O1-NEXT: [[ADD:%.*]] = add nsw i32 [[Y]], [[X]]
20+
// CLEAN-O1-NEXT: ret i32 [[ADD]]
21+
//
22+
// UBSAN-O1-LABEL: define dso_local noundef i32 @overflow(
23+
// UBSAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
24+
// UBSAN-O1-NEXT: [[ENTRY:.*:]]
25+
// UBSAN-O1-NEXT: [[TMP0:%.*]] = add i32 [[X]], [[Y]]
26+
// UBSAN-O1-NEXT: ret i32 [[TMP0]]
27+
//
28+
int overflow(int x, int y) {
29+
return x + y;
30+
}

0 commit comments

Comments
 (0)