John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s |
| 2 | |
Mike Stump | 947b3e2 | 2009-04-02 01:14:26 +0000 | [diff] [blame] | 3 | unsigned int ui, uj, uk; |
| 4 | int i, j, k; |
| 5 | |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 6 | // CHECK: define void @test0() |
| 7 | void test0() { |
| 8 | // -ftrapv doesn't affect unsigned arithmetic. |
| 9 | // CHECK: [[T1:%.*]] = load i32* @uj |
| 10 | // CHECK-NEXT: [[T2:%.*]] = load i32* @uk |
| 11 | // CHECK-NEXT: [[T3:%.*]] = add i32 [[T1]], [[T2]] |
| 12 | // CHECK-NEXT: store i32 [[T3]], i32* @ui |
Mike Stump | 947b3e2 | 2009-04-02 01:14:26 +0000 | [diff] [blame] | 13 | ui = uj + uk; |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 14 | |
| 15 | // CHECK: [[T1:%.*]] = load i32* @j |
| 16 | // CHECK-NEXT: [[T2:%.*]] = load i32* @k |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 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 |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 20 | // CHECK-NEXT: br i1 [[T5]] |
Chris Lattner | 93a0035 | 2010-08-07 00:20:46 +0000 | [diff] [blame] | 21 | // CHECK: call void @llvm.trap() |
Mike Stump | 947b3e2 | 2009-04-02 01:14:26 +0000 | [diff] [blame] | 22 | i = j + k; |
| 23 | } |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 24 | |
| 25 | // CHECK: define void @test1() |
| 26 | void test1() { |
| 27 | extern void opaque(int); |
| 28 | opaque(i++); |
| 29 | |
| 30 | // CHECK: [[T1:%.*]] = load i32* @i |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 31 | // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) |
| 32 | // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 |
| 33 | // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 34 | // CHECK-NEXT: br i1 [[T4]] |
Chris Lattner | 93a0035 | 2010-08-07 00:20:46 +0000 | [diff] [blame] | 35 | // CHECK: call void @llvm.trap() |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | // CHECK: define void @test2() |
| 39 | void test2() { |
| 40 | extern void opaque(int); |
| 41 | opaque(++i); |
| 42 | |
| 43 | // CHECK: [[T1:%.*]] = load i32* @i |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 44 | // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) |
| 45 | // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 |
| 46 | // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 47 | // CHECK-NEXT: br i1 [[T4]] |
Chris Lattner | 93a0035 | 2010-08-07 00:20:46 +0000 | [diff] [blame] | 48 | // CHECK: call void @llvm.trap() |
John McCall | 401be6b | 2010-08-05 17:39:44 +0000 | [diff] [blame] | 49 | } |