File tree 1 file changed +13
-2
lines changed
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>(
837
837
dst,
838
838
count,
839
839
} ) => {
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) ;
841
846
let src = codegen_operand ( fx, src) . load_scalar ( fx) ;
842
847
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) ;
844
855
}
845
856
}
846
857
}
You can’t perform that action at this time.
0 commit comments