2023-05-20 01:30:59 -04:00
|
|
|
// revisions:m68k wasm x86_64-linux x86_64-windows i686-linux i686-windows
|
2023-05-13 21:54:54 -04:00
|
|
|
|
|
|
|
//[m68k] compile-flags: --target m68k-unknown-linux-gnu
|
|
|
|
//[m68k] needs-llvm-components: m68k
|
|
|
|
//[wasm] compile-flags: --target wasm32-unknown-emscripten
|
|
|
|
//[wasm] needs-llvm-components: webassembly
|
|
|
|
//[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
|
|
|
|
//[x86_64-linux] needs-llvm-components: x86
|
|
|
|
//[x86_64-windows] compile-flags: --target x86_64-pc-windows-msvc
|
|
|
|
//[x86_64-windows] needs-llvm-components: x86
|
2023-05-20 01:30:59 -04:00
|
|
|
//[i686-linux] compile-flags: --target i686-unknown-linux-gnu
|
|
|
|
//[i686-linux] needs-llvm-components: x86
|
|
|
|
//[i686-windows] compile-flags: --target i686-pc-windows-msvc
|
|
|
|
//[i686-windows] needs-llvm-components: x86
|
2023-05-13 21:54:54 -04:00
|
|
|
|
2022-10-31 20:38:40 -07:00
|
|
|
// Tests that `byval` alignment is properly specified (#80127).
|
2023-05-20 01:30:59 -04:00
|
|
|
// The only targets that use `byval` are m68k, wasm, x86-64, and x86.
|
2023-05-13 21:54:54 -04:00
|
|
|
// Note also that Windows mandates a by-ref ABI here, so it does not use byval.
|
|
|
|
|
|
|
|
#![feature(no_core, lang_items)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![no_std]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
#[lang="sized"] trait Sized { }
|
|
|
|
#[lang="freeze"] trait Freeze { }
|
|
|
|
#[lang="copy"] trait Copy { }
|
|
|
|
|
|
|
|
impl Copy for i32 {}
|
|
|
|
impl Copy for i64 {}
|
2022-10-31 20:38:40 -07:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// on i686-windows, this should be passed on stack using `byval`
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct NaturalAlign8 {
|
|
|
|
a: i64,
|
|
|
|
b: i64,
|
|
|
|
c: i64
|
|
|
|
}
|
|
|
|
|
|
|
|
// on i686-windows, this should be passed by reference (because the alignment is requested/forced),
|
|
|
|
// even though it has the exact same layout as `NaturalAlign8` (!!!)
|
|
|
|
#[repr(C)]
|
|
|
|
#[repr(align(8))]
|
|
|
|
pub struct ForceAlign8 {
|
|
|
|
a: i64,
|
|
|
|
b: i64,
|
|
|
|
c: i64
|
|
|
|
}
|
|
|
|
|
2022-10-31 20:38:40 -07:00
|
|
|
#[repr(C)]
|
|
|
|
#[repr(align(16))]
|
2023-05-20 15:32:37 -04:00
|
|
|
pub struct ForceAlign16 {
|
2022-10-31 20:38:40 -07:00
|
|
|
a: [i32; 16],
|
2023-05-13 21:54:54 -04:00
|
|
|
b: i8
|
2022-10-31 20:38:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
2023-05-20 15:32:37 -04:00
|
|
|
// m68k: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}})
|
|
|
|
|
|
|
|
// wasm: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}})
|
|
|
|
|
|
|
|
// x86_64-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}})
|
|
|
|
|
|
|
|
// x86_64-windows: declare void @natural_align_8(
|
|
|
|
// x86_64-windows-NOT: byval
|
|
|
|
// x86_64-windows-SAME: align 8{{.*}})
|
|
|
|
|
|
|
|
// i686-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}})
|
|
|
|
|
|
|
|
// i686-windows: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}})
|
|
|
|
fn natural_align_8(x: NaturalAlign8);
|
|
|
|
|
|
|
|
// m68k: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}})
|
|
|
|
|
|
|
|
// wasm: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}})
|
|
|
|
|
|
|
|
// x86_64-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}})
|
|
|
|
|
|
|
|
// x86_64-windows: declare void @force_align_8(
|
|
|
|
// x86_64-windows-NOT: byval
|
|
|
|
// x86_64-windows-SAME: align 8{{.*}})
|
|
|
|
|
|
|
|
// i686-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 4{{.*}})
|
|
|
|
|
|
|
|
// i686-windows: declare void @force_align_8(
|
|
|
|
// i686-windows-NOT: byval
|
|
|
|
// i686-windows-SAME: align 8{{.*}})
|
|
|
|
fn force_align_8(y: ForceAlign8);
|
|
|
|
|
|
|
|
// m68k: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}})
|
2023-05-13 21:54:54 -04:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// wasm: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}})
|
2023-05-13 21:54:54 -04:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// x86_64-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}})
|
2023-05-13 21:54:54 -04:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// x86_64-windows: declare void @force_align_16(
|
2023-05-13 21:54:54 -04:00
|
|
|
// x86_64-windows-NOT: byval
|
|
|
|
// x86_64-windows-SAME: align 16{{.*}})
|
2023-05-20 01:30:59 -04:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// i686-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 4{{.*}})
|
2023-05-20 01:30:59 -04:00
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
// i686-windows: declare void @force_align_16(
|
2023-05-20 01:30:59 -04:00
|
|
|
// i686-windows-NOT: byval
|
|
|
|
// i686-windows-SAME: align 16{{.*}})
|
2023-05-20 15:32:37 -04:00
|
|
|
fn force_align_16(z: ForceAlign16);
|
2022-10-31 20:38:40 -07:00
|
|
|
}
|
|
|
|
|
2023-05-20 15:32:37 -04:00
|
|
|
pub unsafe fn main(x: NaturalAlign8, y: ForceAlign8, z: ForceAlign16) {
|
|
|
|
natural_align_8(x);
|
|
|
|
force_align_8(y);
|
|
|
|
force_align_16(z);
|
2022-10-31 20:38:40 -07:00
|
|
|
}
|