1 // compile-flags: -C no-prepopulate-passes
5 // Hack to get the correct size for the length part in slices
6 // CHECK: @helper([[USIZE:i[0-9]+]] %_1)
8 pub fn helper(_: usize) {
11 // CHECK-LABEL: @no_op_slice_adjustment
13 pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
14 // We used to generate an extra alloca and memcpy for the block's trailing expression value, so
15 // check that we copy directly to the return value slot
16 // CHECK: %0 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } undef, {{\[0 x i8\]\*|ptr}} %x.0, 0
17 // CHECK: %1 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %0, [[USIZE]] %x.1, 1
18 // CHECK: ret { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %1
22 // CHECK-LABEL: @no_op_slice_adjustment2
24 pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
25 // We used to generate an extra alloca and memcpy for the function's return value, so check
26 // that there's no memcpy (the slice is written to sret_slot element-wise)
27 // CHECK-NOT: call void @llvm.memcpy.
28 no_op_slice_adjustment(x)