@@ -787,7 +787,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
787787 let llsrcptr = PointerCast ( bcx, llsrcptr, T_ptr ( T_i8 ( ) ) ) ;
788788
789789 let llsize = llsize_of ( ccx, llintype) ;
790- call_memcpy ( bcx, lldestptr, llsrcptr, llsize) ;
790+ call_memcpy ( bcx, lldestptr, llsrcptr, llsize, 1 ) ;
791791 }
792792 }
793793 ~"needs_drop" => {
@@ -846,44 +846,82 @@ pub fn trans_intrinsic(ccx: @CrateContext,
846846 Store ( bcx, morestack_addr, fcx. llretptr . get ( ) ) ;
847847 }
848848 ~"memcpy32" => {
849- let dst_ptr = get_param ( decl, first_real_arg) ;
850- let src_ptr = get_param ( decl, first_real_arg + 1 ) ;
851- let size = get_param ( decl, first_real_arg + 2 ) ;
852- let align = C_i32 ( 1 ) ;
849+ let tp_ty = substs. tys [ 0 ] ;
850+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
851+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
852+ let size = C_i32 ( machine:: llsize_of_real ( ccx, lltp_ty) as i32 ) ;
853+
854+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
855+ let src_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg + 1 ) , T_ptr ( T_i8 ( ) ) ) ;
856+ let count = get_param ( decl, first_real_arg + 2 ) ;
853857 let volatile = C_i1 ( false ) ;
854- let llfn = * bcx. ccx ( ) . intrinsics . get (
855- & ~"llvm. memcpy . p0i8 . p0i8 . i32 ") ;
856- Call ( bcx, llfn, [ dst_ptr, src_ptr, size, align, volatile] ) ;
858+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memcpy . p0i8 . p0i8 . i32 ") ;
859+ Call ( bcx, llfn, [ dst_ptr, src_ptr, Mul ( bcx, size, count) , align, volatile] ) ;
857860 }
858861 ~"memcpy64" => {
859- let dst_ptr = get_param ( decl, first_real_arg) ;
860- let src_ptr = get_param ( decl, first_real_arg + 1 ) ;
861- let size = get_param ( decl, first_real_arg + 2 ) ;
862- let align = C_i32 ( 1 ) ;
862+ let tp_ty = substs. tys [ 0 ] ;
863+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
864+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
865+ let size = C_i64 ( machine:: llsize_of_real ( ccx, lltp_ty) as i64 ) ;
866+
867+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
868+ let src_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg + 1 ) , T_ptr ( T_i8 ( ) ) ) ;
869+ let count = get_param ( decl, first_real_arg + 2 ) ;
863870 let volatile = C_i1 ( false ) ;
864- let llfn = * bcx. ccx ( ) . intrinsics . get (
865- & ~"llvm. memcpy . p0i8 . p0i8 . i64 ") ;
866- Call ( bcx, llfn, [ dst_ptr, src_ptr, size, align, volatile] ) ;
871+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memcpy . p0i8 . p0i8 . i64 ") ;
872+ Call ( bcx, llfn, [ dst_ptr, src_ptr, Mul ( bcx, size, count) , align, volatile] ) ;
867873 }
868874 ~"memmove32" => {
869- let dst_ptr = get_param ( decl, first_real_arg) ;
870- let src_ptr = get_param ( decl, first_real_arg + 1 ) ;
871- let size = get_param ( decl, first_real_arg + 2 ) ;
872- let align = C_i32 ( 1 ) ;
875+ let tp_ty = substs. tys [ 0 ] ;
876+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
877+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
878+ let size = C_i32 ( machine:: llsize_of_real ( ccx, lltp_ty) as i32 ) ;
879+
880+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
881+ let src_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg + 1 ) , T_ptr ( T_i8 ( ) ) ) ;
882+ let count = get_param ( decl, first_real_arg + 2 ) ;
873883 let volatile = C_i1 ( false ) ;
874- let llfn = * bcx. ccx ( ) . intrinsics . get (
875- & ~"llvm. memmove . p0i8 . p0i8 . i32 ") ;
876- Call ( bcx, llfn, [ dst_ptr, src_ptr, size, align, volatile] ) ;
884+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memmove . p0i8 . p0i8 . i32 ") ;
885+ Call ( bcx, llfn, [ dst_ptr, src_ptr, Mul ( bcx, size, count) , align, volatile] ) ;
877886 }
878887 ~"memmove64" => {
879- let dst_ptr = get_param ( decl, first_real_arg) ;
880- let src_ptr = get_param ( decl, first_real_arg + 1 ) ;
881- let size = get_param ( decl, first_real_arg + 2 ) ;
882- let align = C_i32 ( 1 ) ;
888+ let tp_ty = substs. tys [ 0 ] ;
889+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
890+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
891+ let size = C_i64 ( machine:: llsize_of_real ( ccx, lltp_ty) as i64 ) ;
892+
893+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
894+ let src_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg + 1 ) , T_ptr ( T_i8 ( ) ) ) ;
895+ let count = get_param ( decl, first_real_arg + 2 ) ;
896+ let volatile = C_i1 ( false ) ;
897+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memmove . p0i8 . p0i8 . i64 ") ;
898+ Call ( bcx, llfn, [ dst_ptr, src_ptr, Mul ( bcx, size, count) , align, volatile] ) ;
899+ }
900+ ~"memset32" => {
901+ let tp_ty = substs. tys [ 0 ] ;
902+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
903+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
904+ let size = C_i32 ( machine:: llsize_of_real ( ccx, lltp_ty) as i32 ) ;
905+
906+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
907+ let val = get_param ( decl, first_real_arg + 1 ) ;
908+ let count = get_param ( decl, first_real_arg + 2 ) ;
909+ let volatile = C_i1 ( false ) ;
910+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memset . p0i8 . i32 ") ;
911+ Call ( bcx, llfn, [ dst_ptr, val, Mul ( bcx, size, count) , align, volatile] ) ;
912+ }
913+ ~"memset64" => {
914+ let tp_ty = substs. tys [ 0 ] ;
915+ let lltp_ty = type_of:: type_of ( ccx, tp_ty) ;
916+ let align = C_i32 ( machine:: llalign_of_min ( ccx, lltp_ty) as i32 ) ;
917+ let size = C_i64 ( machine:: llsize_of_real ( ccx, lltp_ty) as i64 ) ;
918+
919+ let dst_ptr = PointerCast ( bcx, get_param ( decl, first_real_arg) , T_ptr ( T_i8 ( ) ) ) ;
920+ let val = get_param ( decl, first_real_arg + 1 ) ;
921+ let count = get_param ( decl, first_real_arg + 2 ) ;
883922 let volatile = C_i1 ( false ) ;
884- let llfn = * bcx. ccx ( ) . intrinsics . get (
885- & ~"llvm. memmove . p0i8 . p0i8 . i64 ") ;
886- Call ( bcx, llfn, [ dst_ptr, src_ptr, size, align, volatile] ) ;
923+ let llfn = * bcx. ccx ( ) . intrinsics . get ( & ~"llvm. memset . p0i8 . i64 ") ;
924+ Call ( bcx, llfn, [ dst_ptr, val, Mul ( bcx, size, count) , align, volatile] ) ;
887925 }
888926 ~"sqrtf32" => {
889927 let x = get_param ( decl, first_real_arg) ;
0 commit comments