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
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
#[repr(align(16))]
|
|
|
|
struct Foo {
|
|
|
|
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-13 21:54:54 -04:00
|
|
|
// m68k: declare void @f({{.*}}byval(%Foo) align 16{{.*}})
|
|
|
|
|
|
|
|
// wasm: declare void @f({{.*}}byval(%Foo) align 16{{.*}})
|
|
|
|
|
|
|
|
// x86_64-linux: declare void @f({{.*}}byval(%Foo) align 16{{.*}})
|
|
|
|
|
|
|
|
// x86_64-windows: declare void @f(
|
|
|
|
// x86_64-windows-NOT: byval
|
|
|
|
// x86_64-windows-SAME: align 16{{.*}})
|
2023-05-20 01:30:59 -04:00
|
|
|
|
|
|
|
// i686-linux: declare void @f({{.*}}byval(%Foo) align 4{{.*}})
|
|
|
|
|
|
|
|
// i686-windows: declare void @f(
|
|
|
|
// i686-windows-NOT: byval
|
|
|
|
// i686-windows-SAME: align 16{{.*}})
|
2022-10-31 20:38:40 -07:00
|
|
|
fn f(foo: Foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2023-05-13 21:54:54 -04:00
|
|
|
unsafe { f(Foo { a: [1; 16], b: 2 }) }
|
2022-10-31 20:38:40 -07:00
|
|
|
}
|