Skip to content

Commit 8149066

Browse files
committed
[LoongArch][test] Add some ABI regression tests for empty struct. NFC
How empty structs (not as fields of container struct) are passed in C++ is not explicitly documented in psABI. This patch adds some tests showing the current handing of clang. Some of the results are different from gcc. Following patch(es) will try to fix the mismatch.
1 parent 8a80e33 commit 8149066

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,62 @@ struct s8 test_s8(struct s8 a) {
8181
return a;
8282
}
8383

84+
/// Note: Below tests check how empty structs are passed while above tests check
85+
/// empty structs as fields of container struct are ignored when flattening
86+
/// structs to examine whether the container structs can be passed via FARs.
87+
8488
// CHECK-C: define{{.*}} void @test_s9()
8589
// CHECK-CXX: define{{.*}} i64 @_Z7test_s92s9(i64 {{.*}})
8690
struct s9 { struct empty e; };
8791
struct s9 test_s9(struct s9 a) {
8892
return a;
8993
}
94+
95+
// CHECK-C: define{{.*}} void @test_s10()
96+
// CHECK-CXX: define{{.*}} void @_Z8test_s103s10()
97+
struct s10 { };
98+
struct s10 test_s10(struct s10 a) {
99+
return a;
100+
}
101+
102+
// CHECK-C: define{{.*}} void @test_s11()
103+
// CHECK-CXX: define{{.*}} i64 @_Z8test_s113s11(i64 {{.*}})
104+
struct s11 { struct { } s; };
105+
struct s11 test_s11(struct s11 a) {
106+
return a;
107+
}
108+
109+
// CHECK-C: define{{.*}} void @test_s12()
110+
// CHECK-CXX: define{{.*}} void @_Z8test_s123s12()
111+
struct s12 { int i[0]; };
112+
struct s12 test_s12(struct s12 a) {
113+
return a;
114+
}
115+
116+
// CHECK-C: define{{.*}} void @test_s13()
117+
// CHECK-CXX: define{{.*}} void @_Z8test_s133s13()
118+
struct s13 { struct { } s[0]; };
119+
struct s13 test_s13(struct s13 a) {
120+
return a;
121+
}
122+
123+
// CHECK-C: define{{.*}} void @test_s14()
124+
// CHECK-CXX: define{{.*}} i64 @_Z8test_s143s14(i64 {{.*}})
125+
struct s14 { struct { } s[1]; };
126+
struct s14 test_s14(struct s14 a) {
127+
return a;
128+
}
129+
130+
// CHECK-C: define{{.*}} void @test_s15()
131+
// CHECK-CXX: define{{.*}} void @_Z8test_s153s15()
132+
struct s15 { int : 0; };
133+
struct s15 test_s15(struct s15 a) {
134+
return a;
135+
}
136+
137+
// CHECK-C: define{{.*}} void @test_s16()
138+
// CHECK-CXX: define{{.*}} void @_Z8test_s163s16()
139+
struct s16 { int : 1; };
140+
struct s16 test_s16(struct s16 a) {
141+
return a;
142+
}

0 commit comments

Comments
 (0)