diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-21 14:34:12 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-22 14:28:48 +0200 |
| commit | a27f3e3fd1e4d16160f8885b6b06665b5319f56c (patch) | |
| tree | b033935392cbadf6f85d2dbddf433a88e323aeeb /tests/codegen-llvm/zst-offset.rs | |
| parent | ed93c1783b404d728d4809973a0550eb33cd293f (diff) | |
| download | rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.tar.gz rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.zip | |
Rename `tests/codegen` into `tests/codegen-llvm`
Diffstat (limited to 'tests/codegen-llvm/zst-offset.rs')
| -rw-r--r-- | tests/codegen-llvm/zst-offset.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/codegen-llvm/zst-offset.rs b/tests/codegen-llvm/zst-offset.rs new file mode 100644 index 00000000000..475394a8815 --- /dev/null +++ b/tests/codegen-llvm/zst-offset.rs @@ -0,0 +1,42 @@ +//@ 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 inbounds 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 inbounds i8, {{.+}}, [[USIZE]] 12 + let x = &s.2; + witness(&x); // keep variable in an alloca +} + +#[repr(simd)] +pub struct U64x4([u64; 4]); + +// 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 inbounds i8, {{.+}}, [[USIZE]] 32 + let x = &s.1; + witness(&x); // keep variable in an alloca +} + +#[inline(never)] +fn witness(_: &impl Sized) {} |
