Skip to content

Commit

Permalink
[LoongArch][test] Add some ABI regression tests for empty struct. NFC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SixWeining committed Oct 26, 2023
1 parent 8a80e33 commit 8149066
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,62 @@ struct s8 test_s8(struct s8 a) {
return a;
}

/// Note: Below tests check how empty structs are passed while above tests check
/// empty structs as fields of container struct are ignored when flattening
/// structs to examine whether the container structs can be passed via FARs.

// CHECK-C: define{{.*}} void @test_s9()
// CHECK-CXX: define{{.*}} i64 @_Z7test_s92s9(i64 {{.*}})
struct s9 { struct empty e; };
struct s9 test_s9(struct s9 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s10()
// CHECK-CXX: define{{.*}} void @_Z8test_s103s10()
struct s10 { };
struct s10 test_s10(struct s10 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s11()
// CHECK-CXX: define{{.*}} i64 @_Z8test_s113s11(i64 {{.*}})
struct s11 { struct { } s; };
struct s11 test_s11(struct s11 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s12()
// CHECK-CXX: define{{.*}} void @_Z8test_s123s12()
struct s12 { int i[0]; };
struct s12 test_s12(struct s12 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s13()
// CHECK-CXX: define{{.*}} void @_Z8test_s133s13()
struct s13 { struct { } s[0]; };
struct s13 test_s13(struct s13 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s14()
// CHECK-CXX: define{{.*}} i64 @_Z8test_s143s14(i64 {{.*}})
struct s14 { struct { } s[1]; };
struct s14 test_s14(struct s14 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s15()
// CHECK-CXX: define{{.*}} void @_Z8test_s153s15()
struct s15 { int : 0; };
struct s15 test_s15(struct s15 a) {
return a;
}

// CHECK-C: define{{.*}} void @test_s16()
// CHECK-CXX: define{{.*}} void @_Z8test_s163s16()
struct s16 { int : 1; };
struct s16 test_s16(struct s16 a) {
return a;
}

0 comments on commit 8149066

Please sign in to comment.