summaryrefslogtreecommitdiffstats
path: root/tests/codegen/zst-offset.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/codegen/zst-offset.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen/zst-offset.rs')
-rw-r--r--tests/codegen/zst-offset.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/codegen/zst-offset.rs b/tests/codegen/zst-offset.rs
new file mode 100644
index 000000000..cef4b9bda
--- /dev/null
+++ b/tests/codegen/zst-offset.rs
@@ -0,0 +1,43 @@
+// compile-flags: -C no-prepopulate-passes -Copt-level=0
+
+#![crate_type = "lib"]
+#![feature(repr_simd)]
+
+// Hack to get the correct size for the length part in slices
+// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
+#[no_mangle]
+pub fn helper(_: usize) {
+}
+
+// Check that we correctly generate a GEP for a ZST that is not included in Scalar layout
+// CHECK-LABEL: @scalar_layout
+#[no_mangle]
+pub fn scalar_layout(s: &(u64, ())) {
+// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 8
+ let x = &s.1;
+ witness(&x); // keep variable in an alloca
+}
+
+// Check that we correctly generate a GEP for a ZST that is not included in ScalarPair layout
+// CHECK-LABEL: @scalarpair_layout
+#[no_mangle]
+pub fn scalarpair_layout(s: &(u64, u32, ())) {
+// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12
+ let x = &s.2;
+ witness(&x); // keep variable in an alloca
+}
+
+#[repr(simd)]
+pub struct U64x4(u64, u64, u64, u64);
+
+// Check that we correctly generate a GEP for a ZST that is not included in Vector layout
+// CHECK-LABEL: @vector_layout
+#[no_mangle]
+pub fn vector_layout(s: &(U64x4, ())) {
+// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 32
+ let x = &s.1;
+ witness(&x); // keep variable in an alloca
+}
+
+#[inline(never)]
+fn witness(_: &impl Sized) {}