Skip to content

Commit a058d44

Browse files
committed
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 :).
1 parent 516988b commit a058d44

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

compiler/rustc_codegen_ssa/src/mir/statement.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
120120
ref dst,
121121
ref size,
122122
}) => {
123-
bx.memcpy(
124-
dst,
125-
todo!(),
126-
src,
127-
todo!(),
128-
size,
129-
todo!(),
130-
);
131-
bx
123+
let dst_val = self.codegen_place(&mut bx, dst.as_ref());
124+
let src_val = self.codegen_place(&mut bx, src.as_ref());
125+
let size_val = self.codegen_operand(&mut bx, size);
126+
let size = size_val.immediate_or_packed_pair(&mut bx);
127+
bx.memcpy(
128+
dst_val.llval,
129+
dst_val.align,
130+
src_val.llval,
131+
src_val.align,
132+
size,
133+
// TODO probably want to have this change based on alignment above?
134+
crate::MemFlags::empty(),
135+
);
136+
bx
132137
}
133138
mir::StatementKind::FakeRead(..)
134139
| mir::StatementKind::Retag { .. }

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ impl Debug for Statement<'_> {
16421642
ref src,
16431643
ref dst,
16441644
ref size,
1645-
}) => write!(fmt, "src {:?} -> dst {:?}, {:?} bytes", src, dst, size),
1645+
}) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?},bytes={:?})", src, dst, size),
16461646
Nop => write!(fmt, "nop"),
16471647
}
16481648
}

0 commit comments

Comments
 (0)