2015-06-19 08:39:59 +08:00
|
|
|
// 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
|
2015-06-19 07:59:22 +08:00
|
|
|
|
|
|
|
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_.]*]]
|
|
|
|
|
2015-08-31 01:46:43 +08:00
|
|
|
// {{^|:}} used to match both Debug form of the captured label
|
2015-08-30 23:24:46 +08:00
|
|
|
// cont:
|
|
|
|
// and Release form
|
2015-08-31 01:46:43 +08:00
|
|
|
// ; <label>:14
|
2015-08-30 23:24:46 +08:00
|
|
|
// But avoids false matches inside other numbers such as [114 x i8].
|
2015-08-31 01:46:43 +08:00
|
|
|
// CHECK: {{^|:}}[[L2]]
|
2015-06-19 07:59:22 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.trap()
|
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
|
2015-08-31 01:46:43 +08:00
|
|
|
// CHECK: {{^|:}}[[L1]]
|
2015-06-19 07:59:22 +08:00
|
|
|
// CHECK-NEXT: br i1 %[[B4]], label %[[L3:[0-9a-z_.]*]], label %[[L4:[0-9a-z_.]*]]
|
|
|
|
|
2015-08-31 01:46:43 +08:00
|
|
|
// CHECK: {{^|:}}[[L4]]
|
2015-06-19 07:59:22 +08:00
|
|
|
// CHECK-NEXT: zext
|
|
|
|
// CHECK-NEXT: zext
|
|
|
|
// CHECK-NEXT: __ubsan_handle_divrem_overflow
|
|
|
|
|
2015-08-31 01:46:43 +08:00
|
|
|
// CHECK: {{^|:}}[[L3]]
|
2015-06-19 07:59:22 +08:00
|
|
|
// CHECK-NEXT: sdiv i32 %[[N]], %[[D]]
|
|
|
|
return x / y;
|
|
|
|
}
|