1// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
2
3// Should be 3 hello strings, two global (of different sizes), the rest are
4// shared.
5
6// CHECK: @.str = private unnamed_addr constant [6 x i8] c"hello\00"
7// CHECK: @f1.x = internal global i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0)
8// CHECK: @f2.x = internal global [6 x i8] c"hello\00", align 1
9// CHECK: @f3.x = internal global [8 x i8] c"hello\00\00\00", align 1
10// CHECK: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0) }
11// CHECK: @x = global [3 x i8] c"ola", align 1
12
13void bar(const char *);
14
15// CHECK: define void @f0()
16void f0() {
17  bar("hello");
18  // CHECK: call void @bar({{.*}} @.str
19}
20
21// CHECK: define void @f1()
22void f1() {
23  static char *x = "hello";
24  bar(x);
25  // CHECK: [[T1:%.*]] = load i8** @f1.x
26  // CHECK: call void @bar(i8* [[T1:%.*]])
27}
28
29// CHECK: define void @f2()
30void f2() {
31  static char x[] = "hello";
32  bar(x);
33  // CHECK: call void @bar({{.*}} @f2.x
34}
35
36// CHECK: define void @f3()
37void f3() {
38  static char x[8] = "hello";
39  bar(x);
40  // CHECK: call void @bar({{.*}} @f3.x
41}
42
43void gaz(void *);
44
45// CHECK: define void @f4()
46void f4() {
47  static struct s {
48    char *name;
49  } x = { "hello" };
50  gaz(&x);
51  // CHECK: call void @gaz({{.*}} @f4.x
52}
53
54char x[3] = "ola";
55
56