about summary refs log tree commit diff
path: root/example
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-08-30 15:41:33 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2019-08-30 15:42:07 +0200
commit15b9834d7d37d601fd77db11f8852f9ceb0804d0 (patch)
tree88cbecfbdd562beb49c4ea8f8fb978b2d97d5eb9 /example
parent76d2e085db71370cb34fc12fc544f46e557e743d (diff)
downloadrust-15b9834d7d37d601fd77db11f8852f9ceb0804d0.tar.gz
rust-15b9834d7d37d601fd77db11f8852f9ceb0804d0.zip
Don't copy ByRef passed types to local stack slot when not necessary
Eg when the local is immutable **and** the type is freeze.

This makes the simple raytracer runtime benchmark 1% faster than cg_llvm
without optimizations. Before it was 2% slower.

cc #691
cc #684
Diffstat (limited to 'example')
-rw-r--r--example/example.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/example/example.rs b/example/example.rs
index e8ddc4aaea1..5878e8548d9 100644
--- a/example/example.rs
+++ b/example/example.rs
@@ -202,3 +202,7 @@ fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 {
 fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str {
     &u.1
 }
+
+pub fn reuse_byref_argument_storage(a: (u8, u16, u32)) -> u8 {
+    a.0
+}