Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s |
Chris Lattner | ff933b7 | 2009-12-05 06:49:57 +0000 | [diff] [blame] | 2 | |
| 3 | // CHECK: @test1.x = internal constant [12 x i32] [i32 1 |
Chris Lattner | 761acc1 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 4 | // CHECK: @test2.x = internal constant [13 x i32] [i32 1, |
Chris Lattner | 36a2be1 | 2009-12-05 08:30:04 +0000 | [diff] [blame] | 5 | // CHECK: @test5w = global %0 { i32 2, [4 x i8] undef } |
| 6 | // CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 } |
Chris Lattner | 761acc1 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 7 | |
Chris Lattner | ff933b7 | 2009-12-05 06:49:57 +0000 | [diff] [blame] | 8 | void test1() { |
| 9 | // This should codegen as a "@test1.x" global. |
| 10 | const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 }; |
| 11 | foo(x); |
| 12 | |
| 13 | // CHECK: @test1() |
| 14 | // CHECK: {{call.*@foo.*@test1.x}} |
| 15 | } |
Chris Lattner | 761acc1 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 16 | |
| 17 | |
| 18 | // rdar://7346691 |
| 19 | void test2() { |
| 20 | // This should codegen as a "@test2.x" global + memcpy. |
| 21 | int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 }; |
| 22 | foo(x); |
| 23 | |
| 24 | // CHECK: @test2() |
| 25 | // CHECK: %x = alloca [13 x i32] |
| 26 | // CHECK: call void @llvm.memcpy |
| 27 | // CHECK: call{{.*}}@foo{{.*}}i32* % |
| 28 | } |
| 29 | |
| 30 | |
| 31 | void test3() { |
Chris Lattner | 7c176fa | 2009-12-05 08:33:21 +0000 | [diff] [blame] | 32 | // This should codegen as a memset. |
Chris Lattner | 761acc1 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 33 | int x[100] = { 0 }; |
| 34 | foo(x); |
| 35 | |
| 36 | // CHECK: @test3() |
| 37 | // CHECK: %x = alloca [100 x i32] |
| 38 | // CHECK: call void @llvm.memset |
| 39 | } |
| 40 | |
Chris Lattner | 36a2be1 | 2009-12-05 08:30:04 +0000 | [diff] [blame] | 41 | void test4(void) { |
| 42 | char a[10] = "asdf"; |
| 43 | char b[10] = { "asdf" }; |
| 44 | // CHECK: @test4() |
| 45 | // CHECK: %a = alloca [10 x i8] |
| 46 | // CHECK: %b = alloca [10 x i8] |
| 47 | // CHECK: call void @llvm.memcpy |
| 48 | // CHECK: call void @llvm.memcpy |
| 49 | } |
| 50 | |
| 51 | |
| 52 | union test5u { int i; double d; }; |
| 53 | |
| 54 | void test5() { |
| 55 | union test5u ola = (union test5u) 351; |
| 56 | union test5u olb = (union test5u) 1.0; |
| 57 | } |
| 58 | |
| 59 | union test5u test5w = (union test5u)2; |
| 60 | union test5u test5y = (union test5u)73.0; |
| 61 | |