]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/refs.rs
Rollup merge of #56425 - scottmcm:redo-vec-set_len-docs, r=Centril
[rust.git] / src / test / codegen / refs.rs
1 // compile-flags: -C no-prepopulate-passes
2 // ignore-tidy-linelength
3
4 #![crate_type = "lib"]
5
6 // Hack to get the correct size for the length part in slices
7 // CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
8 #[no_mangle]
9 pub fn helper(_: usize) {
10 }
11
12 // CHECK-LABEL: @ref_dst
13 #[no_mangle]
14 pub fn ref_dst(s: &[u8]) {
15     // We used to generate an extra alloca and memcpy to ref the dst, so check that we copy
16     // directly to the alloca for "x"
17 // CHECK: [[X0:%[0-9]+]] = getelementptr {{.*}} { [0 x i8]*, [[USIZE]] }* %x, i32 0, i32 0
18 // CHECK: store [0 x i8]* %s.0, [0 x i8]** [[X0]]
19 // CHECK: [[X1:%[0-9]+]] = getelementptr {{.*}} { [0 x i8]*, [[USIZE]] }* %x, i32 0, i32 1
20 // CHECK: store [[USIZE]] %s.1, [[USIZE]]* [[X1]]
21
22     let x = &*s;
23     &x; // keep variable in an alloca
24 }