blob: b13000a48c53d428defd4749d206785b4f6c1fd4 [file] [log] [blame]
Chris Lattnerffcd06ea2009-12-05 06:49:57 +00001// RUN: clang-cc -emit-llvm < %s | FileCheck %s
2
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 Lattnerded98d42009-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 Lattnere99c1102009-12-05 08:22:11 +00007
8#include <string.h>
Chris Lattnerffcd06ea2009-12-05 06:49:57 +00009
10void test1() {
11 // This should codegen as a "@test1.x" global.
12 const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 };
13 foo(x);
14
15// CHECK: @test1()
16// CHECK: {{call.*@foo.*@test1.x}}
17}
Chris Lattnere99c1102009-12-05 08:22:11 +000018
19
20// rdar://7346691
21void test2() {
22 // This should codegen as a "@test2.x" global + memcpy.
23 int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 };
24 foo(x);
25
26 // CHECK: @test2()
27 // CHECK: %x = alloca [13 x i32]
28 // CHECK: call void @llvm.memcpy
29 // CHECK: call{{.*}}@foo{{.*}}i32* %
30}
31
32
33void test3() {
34 // This should codegen as a "@test3.x" global + memcpy.
35 int x[100] = { 0 };
36 foo(x);
37
38 // CHECK: @test3()
39 // CHECK: %x = alloca [100 x i32]
40 // CHECK: call void @llvm.memset
41}
42
Chris Lattnerded98d42009-12-05 08:30:04 +000043void test4(void) {
44 char a[10] = "asdf";
45 char b[10] = { "asdf" };
46 // CHECK: @test4()
47 // CHECK: %a = alloca [10 x i8]
48 // CHECK: %b = alloca [10 x i8]
49 // CHECK: call void @llvm.memcpy
50 // CHECK: call void @llvm.memcpy
51}
52
53
54union test5u { int i; double d; };
55
56void test5() {
57 union test5u ola = (union test5u) 351;
58 union test5u olb = (union test5u) 1.0;
59}
60
61union test5u test5w = (union test5u)2;
62union test5u test5y = (union test5u)73.0;
63