1 | // 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 |
2 | |
3 | int f(int x, int y) { |
4 | // CHECK: %[[B1:.*]] = icmp ne i32 %[[D:.*]], 0 |
5 | // CHECK: %[[B2:.*]] = icmp ne i32 %[[N:.*]], -2147483648 |
6 | // CHECK: %[[B3:.*]] = icmp ne i32 %[[D]], -1 |
7 | // CHECK: %[[B4:.*]] = or i1 %[[B2]], %[[B3]] |
8 | // CHECK: br i1 %[[B1]], label %[[L1:[0-9a-z_.]*]], label %[[L2:[0-9a-z_.]*]] |
9 | |
10 | // {{^|:}} used to match both Debug form of the captured label |
11 | // cont: |
12 | // and Release form |
13 | // ; <label>:14 |
14 | // But avoids false matches inside other numbers such as [114 x i8]. |
15 | // CHECK: {{^|:}}[[L2]] |
16 | // CHECK-NEXT: call void @llvm.trap() |
17 | // CHECK-NEXT: unreachable |
18 | |
19 | // CHECK: {{^|:}}[[L1]] |
20 | // CHECK-NEXT: br i1 %[[B4]], label %[[L3:[0-9a-z_.]*]], label %[[L4:[0-9a-z_.]*]] |
21 | |
22 | // CHECK: {{^|:}}[[L4]] |
23 | // CHECK-NEXT: zext |
24 | // CHECK-NEXT: zext |
25 | // CHECK-NEXT: __ubsan_handle_divrem_overflow |
26 | |
27 | // CHECK: {{^|:}}[[L3]] |
28 | // CHECK-NEXT: sdiv i32 %[[N]], %[[D]] |
29 | return x / y; |
30 | } |
31 | |