Chris Lattner | 933f678 | 2010-04-12 21:10:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s |
Chris Lattner | ffcd06ea | 2009-12-05 06:49:57 +0000 | [diff] [blame] | 2 | |
| 3 | // CHECK: @test1.x = internal constant [12 x i32] [i32 1 |
Chris Lattner | e99c110 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 4 | // CHECK: @test2.x = internal constant [13 x i32] [i32 1, |
Chris Lattner | 933f678 | 2010-04-12 21:10:05 +0000 | [diff] [blame] | 5 | // CHECK: @test5w = global %0 { i32 2, [4 x i8] zeroinitializer } |
Chris Lattner | ded98d4 | 2009-12-05 08:30:04 +0000 | [diff] [blame] | 6 | // CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 } |
Chris Lattner | e99c110 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 7 | |
Chris Lattner | 933f678 | 2010-04-12 21:10:05 +0000 | [diff] [blame] | 8 | // CHECK: @test6.x = internal constant %1 { i8 1, i8 2, i32 3, [4 x i8] zeroinitializer } |
Chris Lattner | ffcd06ea | 2009-12-05 06:49:57 +0000 | [diff] [blame] | 9 | void test1() { |
| 10 | // This should codegen as a "@test1.x" global. |
| 11 | const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 }; |
| 12 | foo(x); |
| 13 | |
| 14 | // CHECK: @test1() |
| 15 | // CHECK: {{call.*@foo.*@test1.x}} |
| 16 | } |
Chris Lattner | e99c110 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | // rdar://7346691 |
| 20 | void test2() { |
| 21 | // This should codegen as a "@test2.x" global + memcpy. |
| 22 | int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 }; |
| 23 | foo(x); |
| 24 | |
| 25 | // CHECK: @test2() |
| 26 | // CHECK: %x = alloca [13 x i32] |
| 27 | // CHECK: call void @llvm.memcpy |
| 28 | // CHECK: call{{.*}}@foo{{.*}}i32* % |
| 29 | } |
| 30 | |
| 31 | |
| 32 | void test3() { |
Chris Lattner | 2da786f | 2009-12-05 08:33:21 +0000 | [diff] [blame] | 33 | // This should codegen as a memset. |
Chris Lattner | e99c110 | 2009-12-05 08:22:11 +0000 | [diff] [blame] | 34 | int x[100] = { 0 }; |
| 35 | foo(x); |
| 36 | |
| 37 | // CHECK: @test3() |
| 38 | // CHECK: %x = alloca [100 x i32] |
| 39 | // CHECK: call void @llvm.memset |
| 40 | } |
| 41 | |
Chris Lattner | ded98d4 | 2009-12-05 08:30:04 +0000 | [diff] [blame] | 42 | void test4(void) { |
| 43 | char a[10] = "asdf"; |
| 44 | char b[10] = { "asdf" }; |
| 45 | // CHECK: @test4() |
| 46 | // CHECK: %a = alloca [10 x i8] |
| 47 | // CHECK: %b = alloca [10 x i8] |
| 48 | // CHECK: call void @llvm.memcpy |
| 49 | // CHECK: call void @llvm.memcpy |
| 50 | } |
| 51 | |
| 52 | |
| 53 | union test5u { int i; double d; }; |
| 54 | |
| 55 | void test5() { |
| 56 | union test5u ola = (union test5u) 351; |
| 57 | union test5u olb = (union test5u) 1.0; |
| 58 | } |
| 59 | |
| 60 | union test5u test5w = (union test5u)2; |
| 61 | union test5u test5y = (union test5u)73.0; |
| 62 | |
Chris Lattner | 933f678 | 2010-04-12 21:10:05 +0000 | [diff] [blame] | 63 | |
| 64 | |
| 65 | // PR6660 - sqlite miscompile |
| 66 | struct SelectDest { |
| 67 | unsigned char eDest; |
| 68 | unsigned char affinity; |
| 69 | int iParm; |
| 70 | int iMem; |
| 71 | }; |
| 72 | |
| 73 | void test6() { |
| 74 | struct SelectDest x = {1, 2, 3}; |
| 75 | test6f(&x); |
| 76 | } |