[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / c-strings.c
blob988deee317d4cd75825d2bdb53e9ccffe2e80033
1 // XFAIL: target=aarch64-pc-windows-{{.*}}
2 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
3 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
5 // Should be 3 hello strings, two global (of different sizes), the rest are
6 // shared.
8 // CHECK: @align = {{(dso_local )?}}global i8 [[ALIGN:[0-9]+]]
9 // ITANIUM: @.str = private unnamed_addr constant [6 x i8] c"hello\00"
10 // MSABI: @"??_C@_05CJBACGMB@hello?$AA@" = linkonce_odr dso_local unnamed_addr constant [6 x i8] c"hello\00", comdat, align 1
11 // ITANIUM: @f1.x = internal global ptr @.str
12 // MSABI: @f1.x = internal global ptr @"??_C@_05CJBACGMB@hello?$AA@"
13 // CHECK: @f2.x = internal global [6 x i8] c"hello\00", align [[ALIGN]]
14 // CHECK: @f3.x = internal global [8 x i8] c"hello\00\00\00", align [[ALIGN]]
15 // ITANIUM: @f4.x = internal global %struct.s { ptr @.str }
16 // MSABI: @f4.x = internal global %struct.s { ptr @"??_C@_05CJBACGMB@hello?$AA@" }
17 // CHECK: @x = {{(dso_local )?}}global [3 x i8] c"ola", align [[ALIGN]]
19 // XFAIL: target=hexagon-{{.*}}
20 // Hexagon aligns arrays of size 8+ bytes to a 64-bit boundary, which
21 // fails the check for "@f3.x = ... align [ALIGN]", since ALIGN is derived
22 // from the alignment of a single i8, which is still 1.
24 // XFAIL: target=csky{{.*}}
25 // CSKY aligns arrays of size 4+ bytes to a 32-bit boundary, which
26 // fails the check for "@f2.x = ... align [ALIGN]", since ALIGN is derived
27 // from the alignment of a single i8, which is still 1.
29 #if defined(__s390x__)
30 unsigned char align = 2;
31 #else
32 unsigned char align = 1;
33 #endif
35 void bar(const char *);
37 // CHECK-LABEL: define {{.*}}void @f0()
38 void f0(void) {
39 bar("hello");
40 // ITANIUM: call {{.*}}void @bar({{.*}} @.str
41 // MSABI: call {{.*}}void @bar({{.*}} @"??_C@_05CJBACGMB@hello?$AA@"
44 // CHECK-LABEL: define {{.*}}void @f1()
45 void f1(void) {
46 static char *x = "hello";
47 bar(x);
48 // CHECK: [[T1:%.*]] = load ptr, ptr @f1.x
49 // CHECK: call {{.*}}void @bar(ptr noundef [[T1:%.*]])
52 // CHECK-LABEL: define {{.*}}void @f2()
53 void f2(void) {
54 static char x[] = "hello";
55 bar(x);
56 // CHECK: call {{.*}}void @bar({{.*}} @f2.x
59 // CHECK-LABEL: define {{.*}}void @f3()
60 void f3(void) {
61 static char x[8] = "hello";
62 bar(x);
63 // CHECK: call {{.*}}void @bar({{.*}} @f3.x
66 void gaz(void *);
68 // CHECK-LABEL: define {{.*}}void @f4()
69 void f4(void) {
70 static struct s {
71 char *name;
72 } x = { "hello" };
73 gaz(&x);
74 // CHECK: call {{.*}}void @gaz({{.*}} @f4.x
77 char x[3] = "ola";