1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s
3 unsigned int ui
, uj
, uk
;
6 // CHECK-LABEL: define{{.*}} void @test0()
8 // -ftrapv doesn't affect unsigned arithmetic.
9 // CHECK: [[T1:%.*]] = load i32, ptr @uj
10 // CHECK-NEXT: [[T2:%.*]] = load i32, ptr @uk
11 // CHECK-NEXT: [[T3:%.*]] = add i32 [[T1]], [[T2]]
12 // CHECK-NEXT: store i32 [[T3]], ptr @ui
15 // CHECK: [[T1:%.*]] = load i32, ptr @j
16 // CHECK-NEXT: [[T2:%.*]] = load i32, ptr @k
17 // CHECK-NEXT: [[T3:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]])
18 // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T3]], 0
19 // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T3]], 1
20 // CHECK-NEXT: [[T6:%.*]] = xor i1 [[T5]], true
21 // CHECK-NEXT: br i1 [[T6]]
22 // CHECK: call void @llvm.ubsantrap(i8 0)
26 // CHECK-LABEL: define{{.*}} void @test1()
28 extern void opaque(int);
31 // CHECK: [[T1:%.*]] = load i32, ptr @i
32 // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1)
33 // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0
34 // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1
35 // CHECK-NEXT: [[T5:%.*]] = xor i1 [[T4]], true
36 // CHECK-NEXT: br i1 [[T5]]
37 // CHECK: call void @llvm.ubsantrap(i8 0)
40 // CHECK-LABEL: define{{.*}} void @test2()
42 extern void opaque(int);
45 // CHECK: [[T1:%.*]] = load i32, ptr @i
46 // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1)
47 // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0
48 // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1
49 // CHECK-NEXT: [[T5:%.*]] = xor i1 [[T4]], true
50 // CHECK-NEXT: br i1 [[T5]]
51 // CHECK: call void @llvm.ubsantrap(i8 0)
54 // CHECK-LABEL: define{{.*}} void @test3(
55 void test3(int a
, int b
, float c
, float d
) {
56 // CHECK-NOT: @llvm.trap