Skip to content

Commit 8fdd5e0

Browse files
convert codegen/repr/transparent-* tests to no_core, fix discrepancies
1 parent 549eac3 commit 8fdd5e0

6 files changed

+210
-52
lines changed

tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
//@ compile-flags: -C no-prepopulate-passes
2-
//@ only-loongarch64
3-
//@ only-linux
1+
//@ compile-flags: -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu
2+
//@ needs-llvm-components: loongarch
43

4+
#![feature(no_core, lang_items)]
55
#![crate_type = "lib"]
6+
#![no_std]
7+
#![no_core]
8+
9+
#[lang="sized"] trait Sized { }
10+
#[lang="freeze"] trait Freeze { }
11+
#[lang="copy"] trait Copy { }
612

713
// CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i)
814
#[no_mangle]
@@ -254,7 +260,7 @@ pub struct IntDoubleInt {
254260
#[no_mangle]
255261
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
256262

257-
// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) align 8 dereferenceable(24) %_0)
263+
// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret([24 x i8]) align 8 dereferenceable(24) %_0)
258264
#[no_mangle]
259265
pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
260266
IntDoubleInt { a: 1, b: 2., c: 3 }

tests/codegen/repr/transparent-imm-array.rs

+36-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
1-
//@ revisions: arm mips thumb wasm32
1+
//@ revisions: arm-linux arm-android armv7-linux armv7-android mips thumb sparc
22
//@ compile-flags: -C no-prepopulate-passes
3-
//
4-
//@[arm] only-arm
5-
//@[mips] only-mips
6-
//@[thumb] only-thumb
7-
//@[wasm32] only-wasm32
8-
//@ ignore-emscripten
3+
4+
//@[arm-linux] compile-flags: --target arm-unknown-linux-gnueabi
5+
//@[arm-linux] needs-llvm-components: arm
6+
//@[arm-android] compile-flags: --target arm-linux-androideabi
7+
//@[arm-android] needs-llvm-components: arm
8+
//@[armv7-linux] compile-flags: --target armv7-unknown-linux-gnueabi
9+
//@[armv7-linux] needs-llvm-components: arm
10+
//@[armv7-android] compile-flags: --target armv7-linux-androideabi
11+
//@[armv7-android] needs-llvm-components: arm
12+
//@[mips] compile-flags: --target mips-unknown-linux-gnu
13+
//@[mips] needs-llvm-components: mips
14+
//@[thumb] compile-flags: --target thumbv7neon-linux-androideabi
15+
//@[thumb] needs-llvm-components: arm
16+
//@[sparc] compile-flags: --target sparc-unknown-linux-gnu
17+
//@[sparc] needs-llvm-components: sparc
18+
919
// See ./transparent.rs
1020
// Some platforms pass large aggregates using immediate arrays in LLVMIR
1121
// Other platforms pass large aggregates using struct pointer in LLVMIR
1222
// This covers the "immediate array" case.
1323

14-
#![feature(transparent_unions)]
24+
#![feature(no_core, lang_items, transparent_unions)]
25+
#![crate_type = "lib"]
26+
#![no_std]
27+
#![no_core]
28+
29+
#[lang="sized"] trait Sized { }
30+
#[lang="freeze"] trait Freeze { }
31+
#[lang="copy"] trait Copy { }
1532

16-
#![crate_type="lib"]
33+
impl Copy for [u32; 16] {}
34+
impl Copy for BigS {}
35+
impl Copy for BigU {}
1736

1837

19-
#[derive(Clone, Copy)]
2038
#[repr(C)]
2139
pub struct BigS([u32; 16]);
2240

@@ -33,24 +51,23 @@ pub enum TeBigS {
3351
Variant(BigS),
3452
}
3553

36-
// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32]
54+
// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [16 x i32]
3755
#[no_mangle]
3856
pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
3957

40-
// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32]
58+
// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
4159
#[no_mangle]
4260
pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
4361

44-
// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32]
62+
// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
4563
#[no_mangle]
4664
pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
4765

48-
// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32]
66+
// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32]
4967
#[no_mangle]
5068
pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
5169

5270

53-
#[derive(Clone, Copy)]
5471
#[repr(C)]
5572
pub union BigU {
5673
foo: [u32; 16],
@@ -69,18 +86,18 @@ pub enum TeBigU {
6986
Variant(BigU),
7087
}
7188

72-
// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32]
89+
// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [16 x i32]
7390
#[no_mangle]
7491
pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
7592

76-
// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32]
93+
// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
7794
#[no_mangle]
7895
pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
7996

80-
// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32]
97+
// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
8198
#[no_mangle]
8299
pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
83100

84-
// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32]
101+
// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32]
85102
#[no_mangle]
86103
pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }

tests/codegen/repr/transparent-mips64.rs

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
//@ compile-flags: -C no-prepopulate-passes
2-
//
1+
//@ revisions: mips64 mips64el
2+
3+
//@[mips64] compile-flags: -C no-prepopulate-passes --target mips64-unknown-linux-gnuabi64
4+
//@[mips64] needs-llvm-components: mips
5+
//@[mips64el] compile-flags: -C no-prepopulate-passes --target mips64el-unknown-linux-gnuabi64
6+
//@[mips64el] needs-llvm-components: mips
37

4-
//@ only-mips64
58
// See ./transparent.rs
69

7-
#![feature(transparent_unions)]
10+
#![feature(no_core, lang_items, transparent_unions)]
11+
#![crate_type = "lib"]
12+
#![no_std]
13+
#![no_core]
814

9-
#![crate_type="lib"]
15+
#[lang="sized"] trait Sized { }
16+
#[lang="freeze"] trait Freeze { }
17+
#[lang="copy"] trait Copy { }
1018

19+
impl Copy for [u32; 16] {}
20+
impl Copy for BigS {}
21+
impl Copy for BigU {}
1122

12-
#[derive(Clone, Copy)]
1323
#[repr(C)]
1424
pub struct BigS([u32; 16]);
1525

@@ -26,24 +36,23 @@ pub enum TeBigS {
2636
Variant(BigS),
2737
}
2838

29-
// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [8 x i64]
39+
// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [8 x i64]
3040
#[no_mangle]
3141
pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
3242

33-
// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [8 x i64]
43+
// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
3444
#[no_mangle]
3545
pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
3646

37-
// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [8 x i64]
47+
// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
3848
#[no_mangle]
3949
pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
4050

41-
// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [8 x i64]
51+
// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64]
4252
#[no_mangle]
4353
pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
4454

4555

46-
#[derive(Clone, Copy)]
4756
#[repr(C)]
4857
pub union BigU {
4958
foo: [u32; 16],
@@ -62,18 +71,18 @@ pub enum TeBigU {
6271
Variant(BigU),
6372
}
6473

65-
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [8 x i64]
74+
// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [8 x i64]
6675
#[no_mangle]
6776
pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
6877

69-
// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [8 x i64]
78+
// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
7079
#[no_mangle]
7180
pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
7281

73-
// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [8 x i64]
82+
// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
7483
#[no_mangle]
7584
pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
7685

77-
// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [8 x i64]
86+
// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64]
7887
#[no_mangle]
7988
pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//@ compile-flags: -O -C no-prepopulate-passes --target sparc64-unknown-linux-gnu
2+
//@ needs-llvm-components: sparc
3+
4+
// See ./transparent.rs
5+
6+
#![feature(no_core, lang_items, transparent_unions)]
7+
#![crate_type = "lib"]
8+
#![no_std]
9+
#![no_core]
10+
11+
#[lang="sized"] trait Sized { }
12+
#[lang="freeze"] trait Freeze { }
13+
#[lang="copy"] trait Copy { }
14+
15+
impl Copy for [u32; 16] {}
16+
impl Copy for BigS {}
17+
impl Copy for BigU {}
18+
19+
20+
#[repr(C)]
21+
pub struct BigS([u32; 16]);
22+
23+
#[repr(transparent)]
24+
pub struct TsBigS(BigS);
25+
26+
#[repr(transparent)]
27+
pub union TuBigS {
28+
field: BigS,
29+
}
30+
31+
#[repr(transparent)]
32+
pub enum TeBigS {
33+
Variant(BigS),
34+
}
35+
36+
// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], ptr
37+
// CHECK-NOT: byval
38+
// CHECK-SAME: %{{[0-9a-z_]+}})
39+
#[no_mangle]
40+
pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
41+
42+
// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
43+
// CHECK-NOT: byval
44+
// CHECK-SAME: %{{[0-9a-z_]+}})
45+
#[no_mangle]
46+
pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
47+
48+
// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
49+
// CHECK-NOT: byval
50+
// CHECK-SAME: %{{[0-9a-z_]+}})
51+
#[no_mangle]
52+
pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
53+
54+
// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr
55+
// CHECK-NOT: byval
56+
// CHECK-SAME: %{{[0-9a-z_]+}})
57+
#[no_mangle]
58+
pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
59+
60+
61+
#[repr(C)]
62+
pub union BigU {
63+
foo: [u32; 16],
64+
}
65+
66+
#[repr(transparent)]
67+
pub struct TsBigU(BigU);
68+
69+
#[repr(transparent)]
70+
pub union TuBigU {
71+
field: BigU,
72+
}
73+
74+
#[repr(transparent)]
75+
pub enum TeBigU {
76+
Variant(BigU),
77+
}
78+
79+
// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
80+
// CHECK-NOT: byval
81+
// CHECK-SAME: %{{[0-9a-z_]+}})
82+
#[no_mangle]
83+
pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
84+
85+
// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
86+
// CHECK-NOT: byval
87+
// CHECK-SAME: %{{[0-9a-z_]+}})
88+
#[no_mangle]
89+
pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
90+
91+
// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
92+
// CHECK-NOT: byval
93+
// CHECK-SAME: %{{[0-9a-z_]+}})
94+
#[no_mangle]
95+
pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
96+
97+
// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr
98+
// CHECK-NOT: byval
99+
// CHECK-SAME: %{{[0-9a-z_]+}})
100+
#[no_mangle]
101+
pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }

tests/codegen/repr/transparent-struct-ptr.rs

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
//@ revisions: x32 x64 sparc sparc64
1+
//@ revisions: i686-linux i686-freebsd x64-linux x64-apple wasm32
22
//@ compile-flags: -O -C no-prepopulate-passes
3-
//
4-
//@[x32] only-x86
5-
//@[x64] only-x86_64
6-
//@[sparc] only-sparc
7-
//@[sparc64] only-sparc64
8-
//@ ignore-windows
3+
4+
//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu
5+
//@[i686-linux] needs-llvm-components: x86
6+
//@[i686-freebsd] compile-flags: --target i686-unknown-freebsd
7+
//@[i686-freebsd] needs-llvm-components: x86
8+
//@[x64-linux] compile-flags: --target x86_64-unknown-linux-gnu
9+
//@[x64-linux] needs-llvm-components: x86
10+
//@[x64-apple] compile-flags: --target x86_64-apple-darwin
11+
//@[x64-apple] needs-llvm-components: x86
12+
//@[wasm32] compile-flags: --target wasm32-wasi
13+
//@[wasm32] needs-llvm-components: webassembly
14+
915
// See ./transparent.rs
1016
// Some platforms pass large aggregates using immediate arrays in LLVMIR
1117
// Other platforms pass large aggregates using struct pointer in LLVMIR
1218
// This covers the "struct pointer" case.
1319

20+
#![feature(no_core, lang_items, transparent_unions)]
21+
#![crate_type = "lib"]
22+
#![no_std]
23+
#![no_core]
1424

15-
#![feature(transparent_unions)]
25+
#[lang="sized"] trait Sized { }
26+
#[lang="freeze"] trait Freeze { }
27+
#[lang="copy"] trait Copy { }
1628

17-
#![crate_type="lib"]
29+
impl Copy for [u32; 16] {}
30+
impl Copy for BigS {}
31+
impl Copy for BigU {}
1832

1933

20-
#[derive(Clone, Copy)]
2134
#[repr(C)]
2235
pub struct BigS([u32; 16]);
2336

@@ -51,7 +64,6 @@ pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
5164
pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
5265

5366

54-
#[derive(Clone, Copy)]
5567
#[repr(C)]
5668
pub union BigU {
5769
foo: [u32; 16],

tests/codegen/repr/transparent-sysv64.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
//@ only-x86_64
2-
1+
//@ revisions: linux apple windows
32
//@ compile-flags: -C no-prepopulate-passes
43

5-
#![crate_type="lib"]
4+
//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
5+
//@[linux] needs-llvm-components: x86
6+
//@[apple] compile-flags: --target x86_64-apple-darwin
7+
//@[apple] needs-llvm-components: x86
8+
//@[windows] compile-flags: --target x86_64-pc-windows-msvc
9+
//@[windows] needs-llvm-components: x86
10+
11+
#![feature(no_core, lang_items)]
12+
#![crate_type = "lib"]
13+
#![no_std]
14+
#![no_core]
15+
16+
#[lang="sized"] trait Sized { }
17+
#[lang="freeze"] trait Freeze { }
18+
#[lang="copy"] trait Copy { }
619

720
#[repr(C)]
821
pub struct Rgb8 { r: u8, g: u8, b: u8 }

0 commit comments

Comments
 (0)