xref: /llvm-project/clang/test/CodeGen/AArch64/pure-scalable-args-empty-union.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1 // RUN: %clang_cc1        -O3 -triple aarch64 -target-feature +sve -mvscale-min=1 -mvscale-max=1 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK-C
2 // RUN: %clang_cc1 -x c++ -O3 -triple aarch64 -target-feature +sve -mvscale-min=1 -mvscale-max=1 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK-CXX
3 
4 typedef __SVFloat32_t fvec32 __attribute__((arm_sve_vector_bits(128)));
5 
6 // PST containing an empty union: when compiled as C pass it in registers,
7 // when compiled as C++ - in memory.
8 typedef struct {
9   fvec32 x[4];
10   union {} u;
11 } S0;
12 
13 #ifdef __cplusplus
14 extern "C"
15 #endif
16 void use0(S0);
17 
18 void f0(S0 *p) {
19   use0(*p);
20 }
21 // CHECK-C:   declare void @use0(<vscale x 4 x float>, <vscale x 4 x float>, <vscale x 4 x float>, <vscale x 4 x float>)
22 // CHECK-CXX: declare void @use0(ptr noundef)
23 
24 #ifdef __cplusplus
25 
26 // PST containing an empty union with `[[no_unique_address]]`` - pass in registers.
27 typedef struct {
28    fvec32 x[4];
29    [[no_unique_address]]
30    union {} u;
31 } S1;
32 
33 extern "C" void use1(S1);
34 void f1(S1 *p) {
35   use1(*p);
36 }
37 // CHECK-CXX: declare void @use1(<vscale x 4 x float>, <vscale x 4 x float>, <vscale x 4 x float>, <vscale x 4 x float>)
38 
39 #endif // __cplusplus
40