]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/repr-transparent-aggregates-1.rs
Rollup merge of #80269 - pickfire:patch-4, r=joshtriplett
[rust.git] / src / test / codegen / repr-transparent-aggregates-1.rs
1 // compile-flags: -C no-prepopulate-passes
2 //
3
4 // min-system-llvm-version: 12.0
5 // ignore-arm
6 // ignore-aarch64
7 // ignore-mips
8 // ignore-mips64
9 // ignore-powerpc
10 // ignore-powerpc64
11 // ignore-riscv64 see codegen/riscv-abi
12 // ignore-windows
13 // See repr-transparent.rs
14
15 #![feature(transparent_unions)]
16
17 #![crate_type="lib"]
18
19
20 #[derive(Clone, Copy)]
21 #[repr(C)]
22 pub struct BigS([u32; 16]);
23
24 #[repr(transparent)]
25 pub struct TsBigS(BigS);
26
27 #[repr(transparent)]
28 pub union TuBigS {
29     field: BigS,
30 }
31
32 #[repr(transparent)]
33 pub enum TeBigS {
34     Variant(BigS),
35 }
36
37 // CHECK: define{{.*}}void @test_BigS(%BigS* [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], %BigS* [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
38 #[no_mangle]
39 pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
40
41 // CHECK: define{{.*}}void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], %TsBigS* [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
42 #[no_mangle]
43 pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
44
45 // CHECK: define{{.*}}void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], %TuBigS* [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
46 #[no_mangle]
47 pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
48
49 // CHECK: define{{.*}}void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
50 #[no_mangle]
51 pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
52
53
54 #[derive(Clone, Copy)]
55 #[repr(C)]
56 pub union BigU {
57     foo: [u32; 16],
58 }
59
60 #[repr(transparent)]
61 pub struct TsBigU(BigU);
62
63 #[repr(transparent)]
64 pub union TuBigU {
65     field: BigU,
66 }
67
68 #[repr(transparent)]
69 pub enum TeBigU {
70     Variant(BigU),
71 }
72
73 // CHECK: define{{.*}}void @test_BigU(%BigU* [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], %BigU* [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
74 #[no_mangle]
75 pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
76
77 // CHECK: define{{.*}}void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], %TsBigU* [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
78 #[no_mangle]
79 pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
80
81 // CHECK: define{{.*}}void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], %TuBigU* [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
82 #[no_mangle]
83 pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
84
85 // CHECK: define{{.*}}void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
86 #[no_mangle]
87 pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }