about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2017-03-07 00:19:48 +0900
committertopecongiro <seuchida@gmail.com>2017-03-07 14:01:19 +0900
commit7dc36e9d9991608c59ac9e40e89573318cd08b74 (patch)
treedd8699df20f882b11b9ddc1bf22558ad4b1737a1 /src/test/codegen
parentb04ebef43242ade6be8968694caf56a0fb00a4d3 (diff)
downloadrust-7dc36e9d9991608c59ac9e40e89573318cd08b74.tar.gz
rust-7dc36e9d9991608c59ac9e40e89573318cd08b74.zip
Add tests for issues with the 'E-needtest' label.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/issue-15953.rs39
1 files changed, 39 insertions, 0 deletions
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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<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);
+}