blob: ff86619117ad7bb25d869e9c0660f376d5a73d32 [file] [log] [blame]
Dmitri Gribenko57e2a162013-01-25 00:06:54 +00001// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
Daniel Dunbar61432932008-08-13 23:20:05 +00002
Dmitri Gribenko57e2a162013-01-25 00:06:54 +00003// Should be 3 hello strings, two global (of different sizes), the rest are
4// shared.
Daniel Dunbar61432932008-08-13 23:20:05 +00005
Ulrich Weigandb8409212013-05-06 16:26:41 +00006// CHECK: @align = global i8 [[ALIGN:[0-9]+]]
Dmitri Gribenko57e2a162013-01-25 00:06:54 +00007// CHECK: @.str = private unnamed_addr constant [6 x i8] c"hello\00"
8// CHECK: @f1.x = internal global i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0)
Ulrich Weigandb8409212013-05-06 16:26:41 +00009// CHECK: @f2.x = internal global [6 x i8] c"hello\00", align [[ALIGN]]
10// CHECK: @f3.x = internal global [8 x i8] c"hello\00\00\00", align [[ALIGN]]
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000011// CHECK: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0) }
Ulrich Weigandb8409212013-05-06 16:26:41 +000012// CHECK: @x = global [3 x i8] c"ola", align [[ALIGN]]
13
14#if defined(__s390x__)
15unsigned char align = 2;
16#else
17unsigned char align = 1;
18#endif
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000019
20void bar(const char *);
21
Stephen Lin93ab6bf2013-08-15 06:47:53 +000022// CHECK-LABEL: define void @f0()
Daniel Dunbar61432932008-08-13 23:20:05 +000023void f0() {
24 bar("hello");
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000025 // CHECK: call void @bar({{.*}} @.str
Daniel Dunbar61432932008-08-13 23:20:05 +000026}
27
Stephen Lin93ab6bf2013-08-15 06:47:53 +000028// CHECK-LABEL: define void @f1()
Daniel Dunbar61432932008-08-13 23:20:05 +000029void f1() {
30 static char *x = "hello";
31 bar(x);
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000032 // CHECK: [[T1:%.*]] = load i8** @f1.x
33 // CHECK: call void @bar(i8* [[T1:%.*]])
Daniel Dunbar61432932008-08-13 23:20:05 +000034}
35
Stephen Lin93ab6bf2013-08-15 06:47:53 +000036// CHECK-LABEL: define void @f2()
Daniel Dunbar61432932008-08-13 23:20:05 +000037void f2() {
38 static char x[] = "hello";
39 bar(x);
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000040 // CHECK: call void @bar({{.*}} @f2.x
Daniel Dunbar61432932008-08-13 23:20:05 +000041}
42
Stephen Lin93ab6bf2013-08-15 06:47:53 +000043// CHECK-LABEL: define void @f3()
Daniel Dunbar61432932008-08-13 23:20:05 +000044void f3() {
45 static char x[8] = "hello";
46 bar(x);
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000047 // CHECK: call void @bar({{.*}} @f3.x
Daniel Dunbar61432932008-08-13 23:20:05 +000048}
49
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000050void gaz(void *);
51
Stephen Lin93ab6bf2013-08-15 06:47:53 +000052// CHECK-LABEL: define void @f4()
Daniel Dunbar61432932008-08-13 23:20:05 +000053void f4() {
54 static struct s {
55 char *name;
56 } x = { "hello" };
57 gaz(&x);
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000058 // CHECK: call void @gaz({{.*}} @f4.x
Daniel Dunbar61432932008-08-13 23:20:05 +000059}
60
Nuno Lopes3998d3f2008-08-13 23:28:57 +000061char x[3] = "ola";
Dmitri Gribenko57e2a162013-01-25 00:06:54 +000062