diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGen/trapv.c | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGen/trapv.c')
-rw-r--r-- | clang/test/CodeGen/trapv.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/clang/test/CodeGen/trapv.c b/clang/test/CodeGen/trapv.c new file mode 100644 index 0000000..f52dad5 --- /dev/null +++ b/clang/test/CodeGen/trapv.c @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s + +unsigned int ui, uj, uk; +int i, j, k; + +// CHECK: define void @test0() +void test0() { + // -ftrapv doesn't affect unsigned arithmetic. + // CHECK: [[T1:%.*]] = load i32* @uj + // CHECK-NEXT: [[T2:%.*]] = load i32* @uk + // CHECK-NEXT: [[T3:%.*]] = add i32 [[T1]], [[T2]] + // CHECK-NEXT: store i32 [[T3]], i32* @ui + ui = uj + uk; + + // CHECK: [[T1:%.*]] = load i32* @j + // CHECK-NEXT: [[T2:%.*]] = load i32* @k + // CHECK-NEXT: [[T3:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]]) + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T3]], 0 + // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T3]], 1 + // CHECK-NEXT: br i1 [[T5]] + // CHECK: call void @llvm.trap() + i = j + k; +} + +// CHECK: define void @test1() +void test1() { + extern void opaque(int); + opaque(i++); + + // CHECK: [[T1:%.*]] = load i32* @i + // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 + // CHECK-NEXT: br i1 [[T4]] + // CHECK: call void @llvm.trap() +} + +// CHECK: define void @test2() +void test2() { + extern void opaque(int); + opaque(++i); + + // CHECK: [[T1:%.*]] = load i32* @i + // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1 + // CHECK-NEXT: br i1 [[T4]] + // CHECK: call void @llvm.trap() +} |