File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments