summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/sanitize-trap.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-06-21 14:00:56 +0000
committerdim <dim@FreeBSD.org>2015-06-21 14:00:56 +0000
commit9dd834653b811ad20382e98a87dff824980c9916 (patch)
treea764184c2fc9486979b074250b013a0937ee64e5 /test/CodeGen/sanitize-trap.c
parentbb9760db9b86e93a638ed430d0a14785f7ff9064 (diff)
downloadFreeBSD-src-9dd834653b811ad20382e98a87dff824980c9916.zip
FreeBSD-src-9dd834653b811ad20382e98a87dff824980c9916.tar.gz
Vendor import of clang trunk r240225:
https://llvm.org/svn/llvm-project/cfe/trunk@240225
Diffstat (limited to 'test/CodeGen/sanitize-trap.c')
-rw-r--r--test/CodeGen/sanitize-trap.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/CodeGen/sanitize-trap.c b/test/CodeGen/sanitize-trap.c
new file mode 100644
index 0000000..76ac1f0
--- /dev/null
+++ b/test/CodeGen/sanitize-trap.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow,integer-divide-by-zero -fsanitize-trap=integer-divide-by-zero | FileCheck %s
+
+int f(int x, int y) {
+ // CHECK: %[[B1:.*]] = icmp ne i32 %[[D:.*]], 0
+ // CHECK: %[[B2:.*]] = icmp ne i32 %[[N:.*]], -2147483648
+ // CHECK: %[[B3:.*]] = icmp ne i32 %[[D]], -1
+ // CHECK: %[[B4:.*]] = or i1 %[[B2]], %[[B3]]
+ // CHECK: br i1 %[[B1]], label %[[L1:[0-9a-z_.]*]], label %[[L2:[0-9a-z_.]*]]
+
+ // CHECK: [[L2]]
+ // CHECK-NEXT: call void @llvm.trap()
+ // CHECK-NEXT: unreachable
+
+ // CHECK: [[L1]]
+ // CHECK-NEXT: br i1 %[[B4]], label %[[L3:[0-9a-z_.]*]], label %[[L4:[0-9a-z_.]*]]
+
+ // CHECK: [[L4]]
+ // CHECK-NEXT: zext
+ // CHECK-NEXT: zext
+ // CHECK-NEXT: __ubsan_handle_divrem_overflow
+
+ // CHECK: [[L3]]
+ // CHECK-NEXT: sdiv i32 %[[N]], %[[D]]
+ return x / y;
+}
OpenPOWER on IntegriCloud