1 // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefix=CHECK-GNU-C
3 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GNU-CXX
5 // Empty structs are ignored for PCS purposes on Darwin and in C mode elsewhere.
6 // In C++ mode on ELF they consume a register slot though. Functions are
7 // slightly bigger than minimal to make confirmation against actual GCC
11 #define EXTERNC extern "C"
18 // CHECK: define{{.*}} i32 @empty_arg(i32 noundef %a)
19 // CHECK-GNU-C: define{{.*}} i32 @empty_arg(i32 noundef %a)
20 // CHECK-GNU-CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a)
21 EXTERNC
int empty_arg(struct Empty e
, int a
) {
25 // CHECK: define{{.*}} void @empty_ret()
26 // CHECK-GNU-C: define{{.*}} void @empty_ret()
27 // CHECK-GNU-CXX: define{{.*}} void @empty_ret()
28 EXTERNC
struct Empty
empty_ret(void) {
33 // However, what counts as "empty" is a baroque mess. This is super-empty, it's
34 // ignored even in C++ mode. It also has sizeof == 0, violating C++, but that's
41 // CHECK: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
42 // CHECK-GNU-C: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
43 // CHECK-GNU-CXX: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
44 EXTERNC
int super_empty_arg(struct SuperEmpty e
, int a
) {
48 // This is not empty. It has 0 size but consumes a register slot for GCC.
54 // CHECK: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
55 // CHECK-GNU-C: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
56 // CHECK-GNU-CXX: define{{.*}} i32 @sort_of_empty_arg(i8 %e.coerce, i32 noundef %a)
57 EXTERNC
int sort_of_empty_arg(struct Empty e
, int a
) {
61 // CHECK: define{{.*}} void @sort_of_empty_ret()
62 // CHECK-GNU-C: define{{.*}} void @sort_of_empty_ret()
63 // CHECK-GNU-CXX: define{{.*}} void @sort_of_empty_ret()
64 EXTERNC
struct SortOfEmpty
sort_of_empty_ret(void) {