blob: 2b07be24fbb54b50ac322c366b151281c17bf6aa [file] [log] [blame]
Chris Lattner933f6782010-04-12 21:10:05 +00001// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
Chris Lattnerffcd06ea2009-12-05 06:49:57 +00002
3// CHECK: @test1.x = internal constant [12 x i32] [i32 1
Chris Lattnere99c1102009-12-05 08:22:11 +00004// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
Chris Lattner933f6782010-04-12 21:10:05 +00005// CHECK: @test5w = global %0 { i32 2, [4 x i8] zeroinitializer }
Chris Lattnerded98d42009-12-05 08:30:04 +00006// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
Chris Lattnere99c1102009-12-05 08:22:11 +00007
Chris Lattner933f6782010-04-12 21:10:05 +00008// CHECK: @test6.x = internal constant %1 { i8 1, i8 2, i32 3, [4 x i8] zeroinitializer }
Chris Lattnerffcd06ea2009-12-05 06:49:57 +00009void 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 Lattnere99c1102009-12-05 08:22:11 +000017
18
19// rdar://7346691
20void 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
32void test3() {
Chris Lattner2da786f2009-12-05 08:33:21 +000033 // This should codegen as a memset.
Chris Lattnere99c1102009-12-05 08:22:11 +000034 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 Lattnerded98d42009-12-05 08:30:04 +000042void 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
53union test5u { int i; double d; };
54
55void test5() {
56 union test5u ola = (union test5u) 351;
57 union test5u olb = (union test5u) 1.0;
58}
59
60union test5u test5w = (union test5u)2;
61union test5u test5y = (union test5u)73.0;
62
Chris Lattner933f6782010-04-12 21:10:05 +000063
64
65// PR6660 - sqlite miscompile
66struct SelectDest {
67 unsigned char eDest;
68 unsigned char affinity;
69 int iParm;
70 int iMem;
71};
72
73void test6() {
74 struct SelectDest x = {1, 2, 3};
75 test6f(&x);
76}