diff options
Diffstat (limited to 'src/test/codegen/issue-15953.rs')
-rw-r--r-- | src/test/codegen/issue-15953.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/codegen/issue-15953.rs b/src/test/codegen/issue-15953.rs new file mode 100644 index 000000000..28d284289 --- /dev/null +++ b/src/test/codegen/issue-15953.rs @@ -0,0 +1,29 @@ +// 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); +} |