]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/adjustments.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / codegen / adjustments.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: @no_op_slice_adjustment
13 #[no_mangle]
14 pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
15     // We used to generate an extra alloca and memcpy for the block's trailing expression value, so
16     // check that we copy directly to the return value slot
17 // CHECK: %0 = insertvalue { [0 x i8]*, [[USIZE]] } undef, [0 x i8]* %x.0, 0
18 // CHECK: %1 = insertvalue { [0 x i8]*, [[USIZE]] } %0, [[USIZE]] %x.1, 1
19 // CHECK: ret { [0 x i8]*, [[USIZE]] } %1
20     { x }
21 }
22
23 // CHECK-LABEL: @no_op_slice_adjustment2
24 #[no_mangle]
25 pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
26     // We used to generate an extra alloca and memcpy for the function's return value, so check
27     // that there's no memcpy (the slice is written to sret_slot element-wise)
28 // CHECK-NOT: call void @llvm.memcpy.
29     no_op_slice_adjustment(x)
30 }