align-byval test: add cases for <= align 4
This commit is contained in:
parent
ed317e4a47
commit
209ed071ba
@ -29,6 +29,19 @@
|
||||
impl Copy for i32 {}
|
||||
impl Copy for i64 {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct NaturalAlign2 {
|
||||
a: [i16; 16],
|
||||
b: i16,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[repr(align(4))]
|
||||
pub struct ForceAlign4 {
|
||||
a: [i8; 16],
|
||||
b: i8,
|
||||
}
|
||||
|
||||
// on i686-windows, this should be passed on stack using `byval`
|
||||
#[repr(C)]
|
||||
pub struct NaturalAlign8 {
|
||||
@ -37,7 +50,7 @@ pub struct NaturalAlign8 {
|
||||
c: i64
|
||||
}
|
||||
|
||||
// on i686-windows, this should be passed by reference (because the alignment is requested/forced),
|
||||
// on i686-windows, this is passed by reference (because alignment is >4 and requested/forced),
|
||||
// even though it has the exact same layout as `NaturalAlign8` (!!!)
|
||||
#[repr(C)]
|
||||
#[repr(align(8))]
|
||||
@ -55,6 +68,36 @@ pub struct ForceAlign16 {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
// m68k: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}})
|
||||
|
||||
// wasm: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}})
|
||||
|
||||
// x86_64-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}})
|
||||
|
||||
// x86_64-windows: declare void @natural_align_2(
|
||||
// x86_64-windows-NOT: byval
|
||||
// x86_64-windows-SAME: align 2{{.*}})
|
||||
|
||||
// i686-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}})
|
||||
|
||||
// i686-windows: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}})
|
||||
fn natural_align_2(a: NaturalAlign2);
|
||||
|
||||
// m68k: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}})
|
||||
|
||||
// wasm: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}})
|
||||
|
||||
// x86_64-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}})
|
||||
|
||||
// x86_64-windows: declare void @force_align_4(
|
||||
// x86_64-windows-NOT: byval
|
||||
// x86_64-windows-SAME: align 4{{.*}})
|
||||
|
||||
// i686-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}})
|
||||
|
||||
// i686-windows: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}})
|
||||
fn force_align_4(b: ForceAlign4);
|
||||
|
||||
// m68k: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}})
|
||||
|
||||
// wasm: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}})
|
||||
@ -105,7 +148,12 @@ pub struct ForceAlign16 {
|
||||
fn force_align_16(z: ForceAlign16);
|
||||
}
|
||||
|
||||
pub unsafe fn main(x: NaturalAlign8, y: ForceAlign8, z: ForceAlign16) {
|
||||
pub unsafe fn main(
|
||||
a: NaturalAlign2, b: ForceAlign4,
|
||||
x: NaturalAlign8, y: ForceAlign8, z: ForceAlign16
|
||||
) {
|
||||
natural_align_2(a);
|
||||
force_align_4(b);
|
||||
natural_align_8(x);
|
||||
force_align_8(y);
|
||||
force_align_16(z);
|
||||
|
Loading…
Reference in New Issue
Block a user