diff options
Diffstat (limited to 'test/CodeGen/object-size.c')
-rw-r--r-- | test/CodeGen/object-size.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c index 1f16d02..f6c7db8 100644 --- a/test/CodeGen/object-size.c +++ b/test/CodeGen/object-size.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s #define strcpy(dest, src) \ ((__builtin_object_size(dest, 0) != -1ULL) \ @@ -55,7 +55,10 @@ void test6() { // CHECK: define void @test7 void test7() { int i; - // CHECK: = call i64 @llvm.objectsize.i64(i8* {{.*}}@gbuf{{.*}}, i1 false) + // Ensure we only evaluate the side-effect once. + // CHECK: = add + // CHECK-NOT: = add + // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 63) strcpy((++i, gbuf), "Hi there"); } @@ -124,6 +127,7 @@ void test16() { strcpy(gp += 1, "Hi there"); } +// CHECK: @test17 void test17() { // CHECK: store i32 -1 gi = __builtin_object_size(gp++, 0); @@ -134,3 +138,11 @@ void test17() { // CHECK: store i32 0 gi = __builtin_object_size(gp++, 3); } + +// CHECK: @test18 +unsigned test18(int cond) { + int a[4], b[4]; + // CHECK: phi i32* + // CHECK: call i64 @llvm.objectsize.i64 + return __builtin_object_size(cond ? a : b, 0); +} |