| 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 = {{(dso_local )?}}global i8 [[ALIGN:[0-9]+]] |
| 8 |
// ITANIUM: @.str = private unnamed_addr constant [6 x i8] c"hello\00" |
| 9 |
// MSABI: @"??_C@_05CJBACGMB@hello?$AA@" = linkonce_odr dso_local unnamed_addr constant [6 x i8] c"hello\00", comdat, align 1 |
| 10 |
// ITANIUM: @f1.x = internal global ptr @.str |
| 11 |
// MSABI: @f1.x = internal global ptr @"??_C@_05CJBACGMB@hello?$AA@" |
| 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 { ptr @.str } |
| 15 |
// MSABI: @f4.x = internal global %struct.s { ptr @"??_C@_05CJBACGMB@hello?$AA@" } |
| 16 |
// CHECK: @x = {{(dso_local )?}}global [3 x i8] c"ola", align [[ALIGN]] |
| 17 |
|
| 18 |
// XFAIL: target=aarch64-{{.*}}-windows-msvc, target=arm64ec-{{.*}}-windows-msvc |
| 19 |
// Arm64 in MSVC mode aligns arrays to either 32-bit or 64-bit boundaries, which fails |
| 20 |
// various checks above, since ALIGN is derived from the alignment of a single |
| 21 |
// i8, which is still 1. |
| 22 |
|
| 23 |
// XFAIL: target=hexagon-{{.*}} |
| 24 |
// Hexagon aligns arrays of size 8+ bytes to a 64-bit boundary, which |
| 25 |
// fails the check for "@f3.x = ... align [ALIGN]", since ALIGN is derived |
| 26 |
// from the alignment of a single i8, which is still 1. |
| 27 |
|
| 28 |
// XFAIL: target=csky{{.*}} |
| 29 |
// CSKY aligns arrays of size 4+ bytes to a 32-bit boundary, which |
| 30 |
// fails the check for "@f2.x = ... align [ALIGN]", since ALIGN is derived |
| 31 |
// from the alignment of a single i8, which is still 1. |
| 32 |
|
| 33 |
#if defined(__s390x__) |
| 34 |
unsigned char align = 2; |
| 35 |
#else |
| 36 |
unsigned char align = 1; |
| 37 |
#endif |
| 38 |
|
| 39 |
void bar(const char *); |
| 40 |
|
| 41 |
// CHECK-LABEL: define {{.*}}void @f0() |
| 42 |
void f0(void) { |
| 43 |
bar("hello"); |
| 44 |
// ITANIUM: call {{.*}}void @bar({{.*}} @.str |
| 45 |
// MSABI: call {{.*}}void @bar({{.*}} @"??_C@_05CJBACGMB@hello?$AA@" |
| 46 |
} |
| 47 |
|
| 48 |
// CHECK-LABEL: define {{.*}}void @f1() |
| 49 |
void f1(void) { |
| 50 |
static char *x = "hello"; |
| 51 |
bar(x); |
| 52 |
// CHECK: [[T1:%.*]] = load ptr, ptr @f1.x |
| 53 |
// CHECK: call {{.*}}void @bar(ptr noundef [[T1:%.*]]) |
| 54 |
} |
| 55 |
|
| 56 |
// CHECK-LABEL: define {{.*}}void @f2() |
| 57 |
void f2(void) { |
| 58 |
static char x[] = "hello"; |
| 59 |
bar(x); |
| 60 |
// CHECK: call {{.*}}void @bar({{.*}} @f2.x |
| 61 |
} |
| 62 |
|
| 63 |
// CHECK-LABEL: define {{.*}}void @f3() |
| 64 |
void f3(void) { |
| 65 |
static char x[8] = "hello"; |
| 66 |
bar(x); |
| 67 |
// CHECK: call {{.*}}void @bar({{.*}} @f3.x |
| 68 |
} |
| 69 |
|
| 70 |
void gaz(void *); |
| 71 |
|
| 72 |
// CHECK-LABEL: define {{.*}}void @f4() |
| 73 |
void f4(void) { |
| 74 |
static struct s { |
| 75 |
char *name; |
| 76 |
} x = { "hello" }; |
| 77 |
gaz(&x); |
| 78 |
// CHECK: call {{.*}}void @gaz({{.*}} @f4.x |
| 79 |
} |
| 80 |
|
| 81 |
char x[3] = "ola"; |