about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2021-01-23 03:55:41 +0000
committerkadmin <julianknodt@gmail.com>2021-03-09 16:54:14 +0000
commitd30c497de6dc625012293efd29fa2f98a479947b (patch)
tree648bdbb588d91b328eea12e10e27a129cb8f2160
parent83e6251f21984764cac52d5d50408437dc000e57 (diff)
downloadrust-d30c497de6dc625012293efd29fa2f98a479947b.tar.gz
rust-d30c497de6dc625012293efd29fa2f98a479947b.zip
Build StKind::CopyOverlapping
This replaces where it was previously being constructed in intrinsics, with direct construction
of the Statement.
-rw-r--r--src/base.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/base.rs b/src/base.rs
index ba7c82d24c5..8b5ae9e0541 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -837,10 +837,21 @@ fn codegen_stmt<'tcx>(
           dst,
           count,
         }) => {
-            let dst = codegen_operand(fx, dst).load_scalar(fx);
+            let dst = codegen_operand(fx, dst);
+            let pointee = dst
+              .layout()
+              .pointee_info_at(fx, rustc_target::abi::Size::ZERO)
+              .expect("Expected pointer");
+            let dst = dst.load_scalar(fx);
             let src = codegen_operand(fx, src).load_scalar(fx);
             let count = codegen_operand(fx, count).load_scalar(fx);
-            fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, count);
+            let elem_size: u64 = pointee.size.bytes();
+            let bytes = if elem_size != 1 {
+               fx.bcx.ins().imul_imm(count, elem_size as i64)
+            } else {
+               count
+            };
+            fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, bytes);
         }
     }
 }