From 72c734d001a157e0fb38e1feebf6748189d3e1b9 Mon Sep 17 00:00:00 2001 From: kadmin Date: Mon, 5 Oct 2020 20:13:36 +0000 Subject: [PATCH] Update fmt and use of memcpy I'm still not totally sure if this is the right way to implement the memcpy, but that portion compiles correctly now. Now to fix the compile errors everywhere else :). --- .../rustc_codegen_ssa/src/mir/statement.rs | 23 +++++++++++-------- compiler/rustc_middle/src/mir/mod.rs | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs index 2c90054b6c7..b507cb0a823 100644 --- a/compiler/rustc_codegen_ssa/src/mir/statement.rs +++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs @@ -120,15 +120,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ref dst, ref size, }) => { - bx.memcpy( - dst, - todo!(), - src, - todo!(), - size, - todo!(), - ); - bx + let dst_val = self.codegen_place(&mut bx, dst.as_ref()); + let src_val = self.codegen_place(&mut bx, src.as_ref()); + let size_val = self.codegen_operand(&mut bx, size); + let size = size_val.immediate_or_packed_pair(&mut bx); + bx.memcpy( + dst_val.llval, + dst_val.align, + src_val.llval, + src_val.align, + size, + // TODO probably want to have this change based on alignment above? + crate::MemFlags::empty(), + ); + bx } mir::StatementKind::FakeRead(..) | mir::StatementKind::Retag { .. } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 90111d4080c..2db69c27fe8 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1668,7 +1668,7 @@ impl Debug for Statement<'_> { ref src, ref dst, ref size, - }) => write!(fmt, "src {:?} -> dst {:?}, {:?} bytes", src, dst, size), + }) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?},bytes={:?})", src, dst, size), Nop => write!(fmt, "nop"), } }