]> git.lizzy.rs Git - rust.git/blob - tests/codegen/adjustments.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / codegen / adjustments.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4
5 // Hack to get the correct size for the length part in slices
6 // CHECK: @helper([[USIZE:i[0-9]+]] %_1)
7 #[no_mangle]
8 pub fn helper(_: usize) {
9 }
10
11 // CHECK-LABEL: @no_op_slice_adjustment
12 #[no_mangle]
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
19     { x }
20 }
21
22 // CHECK-LABEL: @no_op_slice_adjustment2
23 #[no_mangle]
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)
29 }