diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-06 09:23:02 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-06 09:23:02 +0000 |
| commit | dd5132ce2569a1ef901c92772eb8581aa1705f25 (patch) | |
| tree | 7e0a88c3c6cb70271946aaa95a231b3da55d9f91 /test/CodeGen | |
| parent | 79ade4e028932fcb9dab15e2fb2305ca15ab0f14 (diff) | |
Notes
Diffstat (limited to 'test/CodeGen')
| -rw-r--r-- | test/CodeGen/asm-2.c | 10 | ||||
| -rw-r--r-- | test/CodeGen/asm-inout.c | 18 | ||||
| -rw-r--r-- | test/CodeGen/asm.c | 33 | ||||
| -rw-r--r-- | test/CodeGen/attr-weakref.c | 62 | ||||
| -rw-r--r-- | test/CodeGen/attr-weakref2.c | 54 | ||||
| -rw-r--r-- | test/CodeGen/attributes.c | 6 | ||||
| -rw-r--r-- | test/CodeGen/blockstret.c | 106 | ||||
| -rw-r--r-- | test/CodeGen/builtins-arm.c | 6 | ||||
| -rw-r--r-- | test/CodeGen/builtins-x86.c | 4 | ||||
| -rw-r--r-- | test/CodeGen/builtins.c | 1 |
10 files changed, 260 insertions, 40 deletions
diff --git a/test/CodeGen/asm-2.c b/test/CodeGen/asm-2.c deleted file mode 100644 index 9d73608a4c18..000000000000 --- a/test/CodeGen/asm-2.c +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o %t -triple i386-pc-linux-gnu -O2 -// RUN: not grep "load" %t - -// <rdar://problem/6841383> -int cpuid(unsigned data) { - int a, b; - - asm("xyz" :"=a"(a), "=d"(b) : "a"(data)); - return a + b; -} diff --git a/test/CodeGen/asm-inout.c b/test/CodeGen/asm-inout.c deleted file mode 100644 index 407660927100..000000000000 --- a/test/CodeGen/asm-inout.c +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o %t -// RUN: grep "load i8\*\*\* %p.addr" %t | count 1 -// XFAIL: * - -// PR3800 -void f(void **p) -{ - __asm__ volatile("" :"+m"(*p)); -} - -#if 0 -// FIXME: Once this works again, we must verify that the code below behaves as expected -// See PR4677. -void f() { - unsigned _data = 42; - __asm__("bswap %0":"+r"(_data)); -} -#endif diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index df593d79fa17..bf1c806a2c47 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s void t1(int len) { __asm__ volatile("" : "=&r"(len), "+&r"(len)); } @@ -28,14 +28,16 @@ void t6(void) { __asm__ volatile("" : : "i" (t6)); } -// RUN: grep "T7 NAMED: \$1" %t void t7(int a) { __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4)); + // CHECK: @t7(i32 + // CHECK: T7 NAMED: $1 } -// RUN: grep "T8 NAMED MODIFIER: \${0:c}" %t void t8() { __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4)); + // CHECK: @t8() + // CHECK: T8 NAMED MODIFIER: ${0:c} } // PR3682 @@ -45,9 +47,11 @@ unsigned t9(unsigned int a) { } // PR3908 -// RUN: grep "PR3908 \$1 \$3 \$2 \$0" %t void t10(int r) { __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0))); + +// CHECK: @t10( +// CHECK:PR3908 $1 $3 $2 $0 } @@ -110,3 +114,24 @@ int t16() { ); return 0; } + +// PR6475 +void t17() { + int i; + __asm__ ( "nop": "=m"(i)); + +// CHECK: @t17() +// CHECK: call void asm "nop", "=*m, +} + +// <rdar://problem/6841383> +int t18(unsigned data) { + int a, b; + + asm("xyz" :"=a"(a), "=d"(b) : "a"(data)); + return a + b; +// CHECK: t18(i32 +// CHECK: = call {{.*}}asm "xyz" +// CHECK-NEXT: extractvalue +// CHECK-NEXT: extractvalue +} diff --git a/test/CodeGen/attr-weakref.c b/test/CodeGen/attr-weakref.c new file mode 100644 index 000000000000..c1cc03b668d9 --- /dev/null +++ b/test/CodeGen/attr-weakref.c @@ -0,0 +1,62 @@ +// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s +// RUN: FileCheck --input-file=%t %s + +// CHECK: declare extern_weak void @test1_f() +void test1_f(void); +static void test1_g(void) __attribute__((weakref("test1_f"))); +void test1_h(void) { + test1_g(); +} + +// CHECK: define void @test2_f() +void test2_f(void) {} +static void test2_g(void) __attribute__((weakref("test2_f"))); +void test2_h(void) { + test2_g(); +} + +// CHECK: declare void @test3_f() +void test3_f(void); +static void test3_g(void) __attribute__((weakref("test3_f"))); +void test3_foo(void) { + test3_f(); +} +void test3_h(void) { + test3_g(); +} + +// CHECK: define void @test4_f() +void test4_f(void); +static void test4_g(void) __attribute__((weakref("test4_f"))); +void test4_h(void) { + test4_g(); +} +void test4_f(void) {} + +// CHECK: declare void @test5_f() +void test5_f(void); +static void test5_g(void) __attribute__((weakref("test5_f"))); +void test5_h(void) { + test5_g(); +} +void test5_foo(void) { + test5_f(); +} + +// CHECK: declare extern_weak void @test6_f() +void test6_f(void) __attribute__((weak)); +static void test6_g(void) __attribute__((weakref("test6_f"))); +void test6_h(void) { + test6_g(); +} +void test6_foo(void) { + test6_f(); +} + +// CHECK: declare extern_weak void @test7_f() +void test7_f(void); +static void test7_g(void) __attribute__((weakref("test7_f"))); +static void *const test7_zed = (void *) &test7_g; +void* test7_h(void) { + return test7_zed; +} diff --git a/test/CodeGen/attr-weakref2.c b/test/CodeGen/attr-weakref2.c new file mode 100644 index 000000000000..99760635581d --- /dev/null +++ b/test/CodeGen/attr-weakref2.c @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s +// RUN: FileCheck --input-file=%t %s + +// CHECK: @test1_f = extern_weak global i32 +extern int test1_f; +static int test1_g __attribute__((weakref("test1_f"))); +int test1_h(void) { + return test1_g; +} + +// CHECK: @test2_f = common global i32 0, align 4 +int test2_f; +static int test2_g __attribute__((weakref("test2_f"))); +int test2_h(void) { + return test2_g; +} + +// CHECK: @test3_f = external global i32 +extern int test3_f; +static int test3_g __attribute__((weakref("test3_f"))); +int test3_foo(void) { + return test3_f; +} +int test3_h(void) { + return test3_g; +} + +// CHECK: @test4_f = common global i32 0, align 4 +extern int test4_f; +static int test4_g __attribute__((weakref("test4_f"))); +int test4_h(void) { + return test4_g; +} +int test4_f; + +// CHECK: @test5_f = external global i32 +extern int test5_f; +static int test5_g __attribute__((weakref("test5_f"))); +int test5_h(void) { + return test5_g; +} +int test5_foo(void) { + return test5_f; +} + +// CHECK: @test6_f = extern_weak global i32 +extern int test6_f __attribute__((weak)); +static int test6_g __attribute__((weakref("test6_f"))); +int test6_h(void) { + return test6_g; +} +int test6_foo(void) { + return test6_f; +} diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c index 4fdf1a51762b..770ce766dfba 100644 --- a/test/CodeGen/attributes.c +++ b/test/CodeGen/attributes.c @@ -30,12 +30,6 @@ int t12 __attribute__((section("SECT"))); void __t8() {} void t9() __attribute__((weak, alias("__t8"))); -static void t22(void) __attribute__((weakref("t8"))); -// CHECK: @t22 = alias weak void ()* @t8 - -static void t23(void) __attribute__((weakref, alias("t8"))); -// CHECK: @t23 = alias weak void ()* @t8 - // CHECK: declare extern_weak i32 @t15() int __attribute__((weak_import)) t15(void); int t17() { diff --git a/test/CodeGen/blockstret.c b/test/CodeGen/blockstret.c new file mode 100644 index 000000000000..09292b809f5a --- /dev/null +++ b/test/CodeGen/blockstret.c @@ -0,0 +1,106 @@ +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X64 +// RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32 + +// X64: internal constant %2 { i8** @_NSConcreteGlobalBlock, i32 1879048192 +// X64: store i32 1610612736, i32* %want + +// X32: @_NSConcreteGlobalBlock, i32 1879048192, i32 0, +// X32: store i32 1610612736, i32* %want + +// rdar://7677537 +int printf(const char *, ...); +void *malloc(__SIZE_TYPE__ size); + +typedef struct bigbig { + int array[512]; + char more[32]; +} BigStruct_t; + +BigStruct_t (^global)(void) = ^{ return *(BigStruct_t *)malloc(sizeof(struct bigbig)); }; + +const char * getBlockSignature(void *); + +BigStruct_t foo(int param) { + BigStruct_t x; + BigStruct_t (^f)(int) = ^(int param) { + BigStruct_t *result = malloc(sizeof(BigStruct_t)); + result->array[23] = param; + return *result; + }; + getBlockSignature(f); + return x; +} + +enum { + BLOCK_HAS_COPY_DISPOSE = (1 << 25), + BLOCK_HAS_CXX_OBJ = (1 << 26), + BLOCK_IS_GLOBAL = (1 << 28), + BLOCK_USE_STRET = (1 << 29), + BLOCK_HAS_OBJC_TYPE = (1 << 30) +}; + +struct block_descriptor_big { + unsigned long int reserved; + unsigned long int size; + void (*copy)(void *dst, void *src); // conditional on BLOCK_HAS_COPY_DISPOSE + void (*dispose)(void *); // conditional on BLOCK_HAS_COPY_DISPOSE + const char *signature; // conditional on BLOCK_HAS_OBJC + const char *layout; // conditional on BLOCK_HAS_OBJC +}; +struct block_descriptor_small { + unsigned long int reserved; + unsigned long int size; + const char *signature; // conditional on BLOCK_HAS_OBJC + const char *layout; // conditional on BLOCK_HAS_OBJC +}; + +struct block_layout_abi { // can't change + void *isa; + int flags; + int reserved; + void (*invoke)(void *, ...); + struct block_descriptor_big *descriptor; +}; + +const char *getBlockSignature(void *block) { + struct block_layout_abi *layout = (struct block_layout_abi *)block; + if ((layout->flags & BLOCK_HAS_OBJC_TYPE) != BLOCK_HAS_OBJC_TYPE) return 0; + if (layout->flags & BLOCK_HAS_COPY_DISPOSE) + return layout->descriptor->signature; + else + return ((struct block_descriptor_small *)layout->descriptor)->signature; +} + +int usesStruct(void *block) { + struct block_layout_abi *layout = (struct block_layout_abi *)block; + int want = BLOCK_HAS_OBJC_TYPE | BLOCK_USE_STRET; + return (layout->flags & want) == want; +} + + +int main(int argc, char *argv[]) { + printf("desired global flags: %d\n", BLOCK_USE_STRET | BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE); + printf("desired stack flags: %d\n", BLOCK_USE_STRET | BLOCK_HAS_OBJC_TYPE); + + printf("should be non-zero: %d\n", usesStruct(global)); + BigStruct_t x; + BigStruct_t (^local)(int) = ^(int param) { + BigStruct_t *result = (BigStruct_t *)malloc(sizeof(BigStruct_t)); + result->array[23] = argc; + return *result; + }; + printf("should be non-zero: %d\n", usesStruct(global)); + printf("should be non-zero: %d\n", usesStruct(local)); + printf("should be zero: %d\n", usesStruct(^void(int x){ })); + return 0; +} + +/* +desired global flags: 1879048192 +desired stack flags: 1610612736 +should be non-zero: 0 +should be non-zero: 0 +should be non-zero: 1 +should be zero: 0 + +*/ diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c new file mode 100644 index 000000000000..555375754959 --- /dev/null +++ b/test/CodeGen/builtins-arm.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o %t %s + +void *f0() +{ + return __builtin_thread_pointer(); +} diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index 2eadd7f884d8..b5878144981f 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -360,8 +360,8 @@ void f0() { tmp_V2LLi = __builtin_ia32_pmuldq128(tmp_V4i, tmp_V4i); tmp_V4i = __builtin_ia32_pmulld128(tmp_V4i, tmp_V4i); tmp_V4f = __builtin_ia32_roundps(tmp_V4f, imm_i_0_16); - // tmp_V4f = __builtin_ia32_roundss(tmp_V4f, tmp_V4f, imm_i_0_16); - // tmp_V2d = __builtin_ia32_roundsd(tmp_V2d, tmp_V2d, imm_i_0_16); + tmp_V4f = __builtin_ia32_roundss(tmp_V4f, tmp_V4f, imm_i_0_16); + tmp_V2d = __builtin_ia32_roundsd(tmp_V2d, tmp_V2d, imm_i_0_16); tmp_V2d = __builtin_ia32_roundpd(tmp_V2d, imm_i_0_16); tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, tmp_i); #endif diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c index 417ca7def5f2..a4424d77428f 100644 --- a/test/CodeGen/builtins.c +++ b/test/CodeGen/builtins.c @@ -118,6 +118,7 @@ int main() { // V(clear_cache, (&N, &N+1)); V(trap, ()); R(extract_return_addr, (&N)); + P(signbit, (1.0)); return 0; } |
