]> git.proxmox.com Git - rustc.git/blame - tests/codegen/adjustments.rs
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / codegen / adjustments.rs
CommitLineData
9c376795 1// compile-flags: -C no-prepopulate-passes -Copt-level=0
b039eaaf
SL
2
3#![crate_type = "lib"]
4
5// Hack to get the correct size for the length part in slices
e1599b0c 6// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
b039eaaf 7#[no_mangle]
abe05a73 8pub fn helper(_: usize) {
b039eaaf
SL
9}
10
11// CHECK-LABEL: @no_op_slice_adjustment
12#[no_mangle]
13pub 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
923072b8
FG
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
b039eaaf
SL
19 { x }
20}
21
22// CHECK-LABEL: @no_op_slice_adjustment2
23#[no_mangle]
24pub 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}