64 lines · c
1// RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm %s -o - | FileCheck %s2 3// SystemZ prefers to align all global variables to two bytes.4 5struct test {6 signed char a;7};8 9char c;10// CHECK-DAG: @c ={{.*}} global i8 0, align 211 12struct test s;13// CHECK-DAG: @s ={{.*}} global %struct.test zeroinitializer, align 214 15extern char ec;16// CHECK-DAG: @ec = external global i8, align 217 18extern struct test es;19// CHECK-DAG: @es = external global %struct.test, align 220 21// Dummy function to make sure external symbols are used.22void func (void)23{24 c = ec;25 s = es;26}27 28// Test that a global variable with an incomplete type gets the minimum29// alignment of 2 per the ABI if no alignment was specified by user.30//31// CHECK-DAG: @VarNoAl {{.*}} align 232// CHECK-DAG: @VarExplAl1 {{.*}} align 133// CHECK-DAG: @VarExplAl4 {{.*}} align 434struct incomplete_ty;35extern struct incomplete_ty VarNoAl;36extern struct incomplete_ty __attribute__((aligned(1))) VarExplAl1;37extern struct incomplete_ty __attribute__((aligned(4))) VarExplAl4;38struct incomplete_ty *fun0 (void) { return &VarNoAl; }39struct incomplete_ty *fun1 (void) { return &VarExplAl1; }40struct incomplete_ty *fun2 (void) { return &VarExplAl4; }41 42// The SystemZ ABI aligns __int128_t to only eight bytes.43 44struct S_int128 { __int128_t B; } Obj_I128;45__int128_t GlobI128;46// CHECK: @Obj_I128 = global %struct.S_int128 zeroinitializer, align 847// CHECK: @GlobI128 = global i128 0, align 848 49 50// Alignment should be respected for coerced argument loads51 52struct arg { long y __attribute__((packed, aligned(4))); };53 54extern struct arg x;55void f(struct arg);56 57void test (void)58{59 f(x);60}61 62// CHECK-LABEL: @test63// CHECK: load i64, ptr @x, align 464