From 7dc36e9d9991608c59ac9e40e89573318cd08b74 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 7 Mar 2017 00:19:48 +0900 Subject: Add tests for issues with the 'E-needtest' label. --- src/test/codegen/issue-15953.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/codegen/issue-15953.rs (limited to 'src/test/codegen') diff --git a/src/test/codegen/issue-15953.rs b/src/test/codegen/issue-15953.rs new file mode 100644 index 00000000000..320ea6b5cc4 --- /dev/null +++ b/src/test/codegen/issue-15953.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that llvm generates `memcpy` for moving a value +// inside a function and moving an argument. + +struct Foo { + x: Vec, +} + +#[inline(never)] +#[no_mangle] +// CHECK: memcpy +fn interior(x: Vec) -> Vec { + let Foo { x } = Foo { x: x }; + x +} + +#[inline(never)] +#[no_mangle] +// CHECK: memcpy +fn exterior(x: Vec) -> Vec { + x +} + +fn main() { + let x = interior(Vec::new()); + println!("{:?}", x); + + let x = exterior(Vec::new()); + println!("{:?}", x); +} -- cgit 1.4.1-3-g733a5