blob: 8bbeb24fe1584a6a8edda7c97e1d9d9de1ceda6a [file] [log] [blame]
Chris Lattner0eea9f92010-04-12 21:10:05 +00001// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
Chris Lattnerff933b72009-12-05 06:49:57 +00002
3// CHECK: @test1.x = internal constant [12 x i32] [i32 1
Chris Lattner761acc12009-12-05 08:22:11 +00004// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
Nuno Lopescdb30b42010-04-16 20:56:35 +00005// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef }
Chris Lattner36a2be12009-12-05 08:30:04 +00006// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
Chris Lattner761acc12009-12-05 08:22:11 +00007
Chris Lattner8ce9e452010-04-13 18:16:19 +00008// CHECK: @test6.x = internal constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
9
10// CHECK: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }]
11
Chris Lattnerff933b72009-12-05 06:49:57 +000012void test1() {
13 // This should codegen as a "@test1.x" global.
14 const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 };
15 foo(x);
16
17// CHECK: @test1()
18// CHECK: {{call.*@foo.*@test1.x}}
19}
Chris Lattner761acc12009-12-05 08:22:11 +000020
21
22// rdar://7346691
23void test2() {
24 // This should codegen as a "@test2.x" global + memcpy.
25 int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 };
26 foo(x);
27
28 // CHECK: @test2()
29 // CHECK: %x = alloca [13 x i32]
30 // CHECK: call void @llvm.memcpy
31 // CHECK: call{{.*}}@foo{{.*}}i32* %
32}
33
34
35void test3() {
Chris Lattner7c176fa2009-12-05 08:33:21 +000036 // This should codegen as a memset.
Chris Lattner761acc12009-12-05 08:22:11 +000037 int x[100] = { 0 };
38 foo(x);
39
40 // CHECK: @test3()
41 // CHECK: %x = alloca [100 x i32]
42 // CHECK: call void @llvm.memset
43}
44
Chris Lattner36a2be12009-12-05 08:30:04 +000045void test4(void) {
46 char a[10] = "asdf";
47 char b[10] = { "asdf" };
48 // CHECK: @test4()
49 // CHECK: %a = alloca [10 x i8]
50 // CHECK: %b = alloca [10 x i8]
51 // CHECK: call void @llvm.memcpy
52 // CHECK: call void @llvm.memcpy
53}
54
55
56union test5u { int i; double d; };
57
58void test5() {
59 union test5u ola = (union test5u) 351;
60 union test5u olb = (union test5u) 1.0;
61}
62
63union test5u test5w = (union test5u)2;
64union test5u test5y = (union test5u)73.0;
65
Chris Lattner0eea9f92010-04-12 21:10:05 +000066
67
68// PR6660 - sqlite miscompile
69struct SelectDest {
70 unsigned char eDest;
71 unsigned char affinity;
72 int iParm;
73 int iMem;
74};
75
76void test6() {
77 struct SelectDest x = {1, 2, 3};
78 test6f(&x);
79}
Chris Lattner8ce9e452010-04-13 18:16:19 +000080
81// rdar://7657600
82struct test7s { int a; int b; } test7[] = {
83 {1, 2},
84 {4},
85};
86