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