• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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", comdat, align 1
10 // ITANIUM: @f1.x = internal global i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0)
11 // MSABI: @f1.x = internal global i8* getelementptr inbounds ([6 x i8], [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], [6 x i8]* @.str, i32 0, i32 0) }
15 // MSABI: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8], [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 // XFAIL: hexagon
19 // Hexagon aligns arrays of size 8+ bytes to a 64-bit boundary, which
20 // fails the check for "@f3.x = ... align [ALIGN]", since ALIGN is derived
21 // from the alignment of a single i8, which is still 1.
22 
23 #if defined(__s390x__)
24 unsigned char align = 2;
25 #else
26 unsigned char align = 1;
27 #endif
28 
29 void bar(const char *);
30 
31 // CHECK-LABEL: define {{.*}}void @f0()
f0()32 void f0() {
33   bar("hello");
34   // ITANIUM: call {{.*}}void @bar({{.*}} @.str
35   // MSABI: call {{.*}}void @bar({{.*}} @"\01??_C@_05CJBACGMB@hello?$AA@"
36 }
37 
38 // CHECK-LABEL: define {{.*}}void @f1()
f1()39 void f1() {
40   static char *x = "hello";
41   bar(x);
42   // CHECK: [[T1:%.*]] = load i8*, i8** @f1.x
43   // CHECK: call {{.*}}void @bar(i8* [[T1:%.*]])
44 }
45 
46 // CHECK-LABEL: define {{.*}}void @f2()
f2()47 void f2() {
48   static char x[] = "hello";
49   bar(x);
50   // CHECK: call {{.*}}void @bar({{.*}} @f2.x
51 }
52 
53 // CHECK-LABEL: define {{.*}}void @f3()
f3()54 void f3() {
55   static char x[8] = "hello";
56   bar(x);
57   // CHECK: call {{.*}}void @bar({{.*}} @f3.x
58 }
59 
60 void gaz(void *);
61 
62 // CHECK-LABEL: define {{.*}}void @f4()
f4()63 void f4() {
64   static struct s {
65     char *name;
66   } x = { "hello" };
67   gaz(&x);
68   // CHECK: call {{.*}}void @gaz({{.*}} @f4.x
69 }
70 
71 char x[3] = "ola";
72 
73