blob: 6d068134b5893d1ff0256b61f289fdbc1b6fc848 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -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,
Chris Lattner36a2be12009-12-05 08:30:04 +00005// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef }
6// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
Chris Lattner761acc12009-12-05 08:22:11 +00007
Chris Lattnerff933b72009-12-05 06:49:57 +00008void 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 Lattner761acc12009-12-05 08:22:11 +000016
17
18// rdar://7346691
19void 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
31void test3() {
Chris Lattner7c176fa2009-12-05 08:33:21 +000032 // This should codegen as a memset.
Chris Lattner761acc12009-12-05 08:22:11 +000033 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 Lattner36a2be12009-12-05 08:30:04 +000041void 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
52union test5u { int i; double d; };
53
54void test5() {
55 union test5u ola = (union test5u) 351;
56 union test5u olb = (union test5u) 1.0;
57}
58
59union test5u test5w = (union test5u)2;
60union test5u test5y = (union test5u)73.0;
61