1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "^define |^entry:" --version 2
2 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm %s -o - \
3 // RUN: | FileCheck -check-prefixes=CHECK-C,CHECK32-C %s
4 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d -target-abi ilp32d -emit-llvm %s -o - \
5 // RUN: | FileCheck -check-prefixes=CHECK-C,CHECK32-C %s
6 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
7 // RUN: | FileCheck -check-prefixes=CHECK-C,CHECK64-C %s
8 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
9 // RUN: | FileCheck -check-prefixes=CHECK-C,CHECK64-C %s
10 // RUN: %clang_cc1 -x c++ -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm %s -o - \
11 // RUN: | FileCheck -check-prefixes=CHECK-CXX,CHECK32-CXX %s
12 // RUN: %clang_cc1 -x c++ -triple riscv32 -target-feature +f -target-feature +d -target-abi ilp32d -emit-llvm %s -o - \
13 // RUN: | FileCheck -check-prefixes=CHECK-CXX,CHECK32-CXX %s
14 // RUN: %clang_cc1 -x c++ -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
15 // RUN: | FileCheck -check-prefixes=CHECK-CXX,CHECK64-CXX %s
16 // RUN: %clang_cc1 -x c++ -triple riscv64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
17 // RUN: | FileCheck -check-prefixes=CHECK-CXX,CHECK64-CXX %s
21 // Fields containing empty structs or unions are ignored when flattening
22 // structs for the hard FP ABIs, even in C++. The rules for arrays of empty
23 // structs or unions are subtle and documented in
24 // <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#hardware-floating-point-calling-convention>.
26 struct empty
{ struct { struct { } e
; }; };
27 struct s1
{ struct empty e
; float f
; };
29 // CHECK-C-LABEL: define dso_local float @test_s1
30 // CHECK-C-SAME: (float [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
33 // CHECK-CXX-LABEL: define dso_local float @_Z7test_s12s1
34 // CHECK-CXX-SAME: (float [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
37 struct s1
test_s1(struct s1 a
) {
41 struct s2
{ struct empty e
; int32_t i
; float f
; };
43 // CHECK-C-LABEL: define dso_local { i32, float } @test_s2
44 // CHECK-C-SAME: (i32 [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
47 // CHECK-CXX-LABEL: define dso_local { i32, float } @_Z7test_s22s2
48 // CHECK-CXX-SAME: (i32 [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
51 struct s2
test_s2(struct s2 a
) {
55 struct s3
{ struct empty e
; float f
; float g
; };
57 // CHECK-C-LABEL: define dso_local { float, float } @test_s3
58 // CHECK-C-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
61 // CHECK-CXX-LABEL: define dso_local { float, float } @_Z7test_s32s3
62 // CHECK-CXX-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
65 struct s3
test_s3(struct s3 a
) {
69 struct s4
{ struct empty e
; float __complex__ c
; };
71 // CHECK-C-LABEL: define dso_local { float, float } @test_s4
72 // CHECK-C-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
75 // CHECK-CXX-LABEL: define dso_local { float, float } @_Z7test_s42s4
76 // CHECK-CXX-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
79 struct s4
test_s4(struct s4 a
) {
83 // An array of empty fields isn't ignored in C++ (this isn't explicit in the
84 // psABI, but matches observed g++ behaviour).
86 struct s5
{ struct empty e
[1]; float f
; };
88 // CHECK-C-LABEL: define dso_local float @test_s5
89 // CHECK-C-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
92 // CHECK32-CXX-LABEL: define dso_local [2 x i32] @_Z7test_s52s5
93 // CHECK32-CXX-SAME: ([2 x i32] [[A_COERCE:%.*]]) #[[ATTR0]] {
94 // CHECK32-CXX: entry:
96 // CHECK64-CXX-LABEL: define dso_local i64 @_Z7test_s52s5
97 // CHECK64-CXX-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
98 // CHECK64-CXX: entry:
100 struct s5
test_s5(struct s5 a
) {
104 struct empty_arr
{ struct { struct { } e
[1]; }; };
105 struct s6
{ struct empty_arr e
; float f
; };
107 // CHECK-C-LABEL: define dso_local float @test_s6
108 // CHECK-C-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
111 // CHECK32-CXX-LABEL: define dso_local [2 x i32] @_Z7test_s62s6
112 // CHECK32-CXX-SAME: ([2 x i32] [[A_COERCE:%.*]]) #[[ATTR0]] {
113 // CHECK32-CXX: entry:
115 // CHECK64-CXX-LABEL: define dso_local i64 @_Z7test_s62s6
116 // CHECK64-CXX-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
117 // CHECK64-CXX: entry:
119 struct s6
test_s6(struct s6 a
) {
123 struct s7
{ struct empty e
[0]; float f
; };
125 // CHECK-C-LABEL: define dso_local float @test_s7
126 // CHECK-C-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
129 // CHECK-CXX-LABEL: define dso_local float @_Z7test_s72s7
130 // CHECK-CXX-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
133 struct s7
test_s7(struct s7 a
) {
137 struct empty_arr0
{ struct { struct { } e
[0]; }; };
138 struct s8
{ struct empty_arr0 e
; float f
; };
140 // CHECK-C-LABEL: define dso_local float @test_s8
141 // CHECK-C-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
144 // CHECK-CXX-LABEL: define dso_local float @_Z7test_s82s8
145 // CHECK-CXX-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
148 struct s8
test_s8(struct s8 a
) {
156 // CHECK-C-LABEL: define dso_local void @test_s9
157 // CHECK-C-SAME: () #[[ATTR0]] {
160 // CHECK32-CXX-LABEL: define dso_local void @_Z7test_s92s9
161 // CHECK32-CXX-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] {
162 // CHECK32-CXX: entry:
164 // CHECK64-CXX-LABEL: define dso_local void @_Z7test_s92s9
165 // CHECK64-CXX-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
166 // CHECK64-CXX: entry:
168 void test_s9(struct s9 a
) {}
170 //// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: