1// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
2// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
3
4// Should be 3 hello strings, two global (of different sizes), the rest are
5// shared.
6
7// CHECK: @align = global i8 [[ALIGN:[0-9]+]]
8// ITANIUM: @.str = private unnamed_addr constant [6 x i8] c"hello\00"
9// MSABI: @"\01??_C@_05CJBACGMB@hello?$AA@" = linkonce_odr unnamed_addr constant [6 x i8] c"hello\00", align 1
10// ITANIUM: @f1.x = internal global i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0)
11// MSABI: @f1.x = internal global i8* getelementptr inbounds ([6 x i8]* @"\01??_C@_05CJBACGMB@hello?$AA@", i32 0, i32 0)
12// CHECK: @f2.x = internal global [6 x i8] c"hello\00", align [[ALIGN]]
13// CHECK: @f3.x = internal global [8 x i8] c"hello\00\00\00", align [[ALIGN]]
14// ITANIUM: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0) }
15// MSABI: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8]* @"\01??_C@_05CJBACGMB@hello?$AA@", i32 0, i32 0) }
16// CHECK: @x = global [3 x i8] c"ola", align [[ALIGN]]
17
18#if defined(__s390x__)
19unsigned char align = 2;
20#else
21unsigned char align = 1;
22#endif
23
24void bar(const char *);
25
26// CHECK-LABEL: define void @f0()
27void f0() {
28  bar("hello");
29  // ITANIUM: call void @bar({{.*}} @.str
30  // MSABI: call void @bar({{.*}} @"\01??_C@_05CJBACGMB@hello?$AA@"
31}
32
33// CHECK-LABEL: define void @f1()
34void f1() {
35  static char *x = "hello";
36  bar(x);
37  // CHECK: [[T1:%.*]] = load i8** @f1.x
38  // CHECK: call void @bar(i8* [[T1:%.*]])
39}
40
41// CHECK-LABEL: define void @f2()
42void f2() {
43  static char x[] = "hello";
44  bar(x);
45  // CHECK: call void @bar({{.*}} @f2.x
46}
47
48// CHECK-LABEL: define void @f3()
49void f3() {
50  static char x[8] = "hello";
51  bar(x);
52  // CHECK: call void @bar({{.*}} @f3.x
53}
54
55void gaz(void *);
56
57// CHECK-LABEL: define void @f4()
58void f4() {
59  static struct s {
60    char *name;
61  } x = { "hello" };
62  gaz(&x);
63  // CHECK: call void @gaz({{.*}} @f4.x
64}
65
66char x[3] = "ola";
67
68