1 // RUN: %clang_cc1 -no-opaque-pointers -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM 2 // RUN: %clang_cc1 -no-opaque-pointers -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 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]* @"??_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]* @"??_C@_05CJBACGMB@hello?$AA@", i32 0, i32 0) } 16 // CHECK: @x = {{(dso_local )?}}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 // XFAIL: csky 24 // CSKY aligns arrays of size 4+ bytes to a 32-bit boundary, which 25 // fails the check for "@f2.x = ... align [ALIGN]", since ALIGN is derived 26 // from the alignment of a single i8, which is still 1. 27 28 #if defined(__s390x__) 29 unsigned char align = 2; 30 #else 31 unsigned char align = 1; 32 #endif 33 34 void bar(const char *); 35 36 // CHECK-LABEL: define {{.*}}void @f0() 37 void f0(void) { 38 bar("hello"); 39 // ITANIUM: call {{.*}}void @bar({{.*}} @.str 40 // MSABI: call {{.*}}void @bar({{.*}} @"??_C@_05CJBACGMB@hello?$AA@" 41 } 42 43 // CHECK-LABEL: define {{.*}}void @f1() 44 void f1(void) { 45 static char *x = "hello"; 46 bar(x); 47 // CHECK: [[T1:%.*]] = load i8*, i8** @f1.x 48 // CHECK: call {{.*}}void @bar(i8* noundef [[T1:%.*]]) 49 } 50 51 // CHECK-LABEL: define {{.*}}void @f2() 52 void f2(void) { 53 static char x[] = "hello"; 54 bar(x); 55 // CHECK: call {{.*}}void @bar({{.*}} @f2.x 56 } 57 58 // CHECK-LABEL: define {{.*}}void @f3() 59 void f3(void) { 60 static char x[8] = "hello"; 61 bar(x); 62 // CHECK: call {{.*}}void @bar({{.*}} @f3.x 63 } 64 65 void gaz(void *); 66 67 // CHECK-LABEL: define {{.*}}void @f4() 68 void f4(void) { 69 static struct s { 70 char *name; 71 } x = { "hello" }; 72 gaz(&x); 73 // CHECK: call {{.*}}void @gaz({{.*}} @f4.x 74 } 75 76 char x[3] = "ola"; 77