Skip to content

Commit b21581d

Browse files
authored
Rollup merge of rust-lang#130466 - davidtwco:aarch64-transparent-test, r=jieyouxu
tests: add repr/transparent test for aarch64 Fixes rust-lang#74396. Moves `transparent-struct-ptr.rs` to `transparent-byval-struct-ptr.rs` and then adds a new `transparent-opaque-ptr.rs` for aarch64.
2 parents 60c3673 + 9a33074 commit b21581d

File tree

3 files changed

+116
-3
lines changed

3 files changed

+116
-3
lines changed

tests/codegen/repr/transparent-struct-ptr.rs renamed to tests/codegen/repr/transparent-byval-struct-ptr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
// See ./transparent.rs
1616
// Some platforms pass large aggregates using immediate arrays in LLVMIR
17-
// Other platforms pass large aggregates using struct pointer in LLVMIR
18-
// This covers the "struct pointer" case.
17+
// Other platforms pass large aggregates using by-value struct pointer in LLVMIR
18+
// Yet more platforms pass large aggregates using opaque pointer in LLVMIR
19+
// This covers the "by-value struct pointer" case.
1920

2021
#![feature(no_core, lang_items, transparent_unions)]
2122
#![crate_type = "lib"]

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
// See ./transparent.rs
2020
// Some platforms pass large aggregates using immediate arrays in LLVMIR
21-
// Other platforms pass large aggregates using struct pointer in LLVMIR
21+
// Other platforms pass large aggregates using by-value struct pointer in LLVMIR
22+
// Yet more platforms pass large aggregates using opaque pointer in LLVMIR
2223
// This covers the "immediate array" case.
2324

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

0 commit comments

Comments
 (0)