summaryrefslogtreecommitdiffstats
path: root/tests/codegen/align-byval-vector.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/codegen/align-byval-vector.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen/align-byval-vector.rs')
-rw-r--r--tests/codegen/align-byval-vector.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/codegen/align-byval-vector.rs b/tests/codegen/align-byval-vector.rs
new file mode 100644
index 000000000..3c8be6596
--- /dev/null
+++ b/tests/codegen/align-byval-vector.rs
@@ -0,0 +1,58 @@
+// revisions:x86-linux x86-darwin
+
+//[x86-linux] compile-flags: --target i686-unknown-linux-gnu
+//[x86-linux] needs-llvm-components: x86
+//[x86-darwin] compile-flags: --target i686-apple-darwin
+//[x86-darwin] needs-llvm-components: x86
+
+// Tests that aggregates containing vector types get their alignment increased to 16 on Darwin.
+
+#![feature(no_core, lang_items, repr_simd, simd_ffi)]
+#![crate_type = "lib"]
+#![no_std]
+#![no_core]
+#![allow(non_camel_case_types)]
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "freeze"]
+trait Freeze {}
+#[lang = "copy"]
+trait Copy {}
+
+#[repr(simd)]
+pub struct i32x4(i32, i32, i32, i32);
+
+#[repr(C)]
+pub struct Foo {
+ a: i32x4,
+ b: i8,
+}
+
+// This tests that we recursively check for vector types, not just at the top level.
+#[repr(C)]
+pub struct DoubleFoo {
+ one: Foo,
+ two: Foo,
+}
+
+extern "C" {
+ // x86-linux: declare void @f({{.*}}byval(%Foo) align 4{{.*}})
+ // x86-darwin: declare void @f({{.*}}byval(%Foo) align 16{{.*}})
+ fn f(foo: Foo);
+
+ // x86-linux: declare void @g({{.*}}byval(%DoubleFoo) align 4{{.*}})
+ // x86-darwin: declare void @g({{.*}}byval(%DoubleFoo) align 16{{.*}})
+ fn g(foo: DoubleFoo);
+}
+
+pub fn main() {
+ unsafe { f(Foo { a: i32x4(1, 2, 3, 4), b: 0 }) }
+
+ unsafe {
+ g(DoubleFoo {
+ one: Foo { a: i32x4(1, 2, 3, 4), b: 0 },
+ two: Foo { a: i32x4(1, 2, 3, 4), b: 0 },
+ })
+ }
+}