Skip to content

Commit d30c497

Browse files
committed
Build StKind::CopyOverlapping
This replaces where it was previously being constructed in intrinsics, with direct construction of the Statement.
1 parent 83e6251 commit d30c497

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/base.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,21 @@ fn codegen_stmt<'tcx>(
837837
dst,
838838
count,
839839
}) => {
840-
let dst = codegen_operand(fx, dst).load_scalar(fx);
840+
let dst = codegen_operand(fx, dst);
841+
let pointee = dst
842+
.layout()
843+
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
844+
.expect("Expected pointer");
845+
let dst = dst.load_scalar(fx);
841846
let src = codegen_operand(fx, src).load_scalar(fx);
842847
let count = codegen_operand(fx, count).load_scalar(fx);
843-
fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, count);
848+
let elem_size: u64 = pointee.size.bytes();
849+
let bytes = if elem_size != 1 {
850+
fx.bcx.ins().imul_imm(count, elem_size as i64)
851+
} else {
852+
count
853+
};
854+
fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, bytes);
844855
}
845856
}
846857
}

0 commit comments

Comments
 (0)