rust/tests/codegen/issue-15953.rs
2023-01-11 09:32:08 +00:00

30 lines
492 B
Rust

// Test that llvm generates `memcpy` for moving a value
// inside a function and moving an argument.
struct Foo {
x: Vec<i32>,
}
#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn interior(x: Vec<i32>) -> Vec<i32> {
let Foo { x } = Foo { x: x };
x
}
#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn exterior(x: Vec<i32>) -> Vec<i32> {
x
}
fn main() {
let x = interior(Vec::new());
println!("{:?}", x);
let x = exterior(Vec::new());
println!("{:?}", x);
}