Skip to content

Commit ae33120

Browse files
committed
rustc: Use memmove in copy_ty. 45% LLVM codegen speed improvement.
1 parent e0985c1 commit ae33120

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,7 @@ fn call_memmove(cx: &@block_ctxt, dst: ValueRef, src: ValueRef,
23802380
let src_ptr = cx.build.PointerCast(src, T_ptr(T_i8()));
23812381
let dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
23822382
let size = cx.build.IntCast(n_bytes, T_i32());
2383-
let align = C_int(0);
2383+
let align = C_int(1);
23842384
let volatile = C_bool(false);
23852385
ret rslt(cx,
23862386
cx.build.Call(memmove,
@@ -2411,7 +2411,12 @@ fn memmove_ty(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: &ty::t) ->
24112411
if ty::type_has_dynamic_size(bcx_tcx(cx), t) {
24122412
let llsz = size_of(cx, t);
24132413
ret call_memmove(llsz.bcx, dst, src, llsz.val);
2414-
} else { ret rslt(cx, cx.build.Store(cx.build.Load(src), dst)); }
2414+
} else if ty::type_is_structural(bcx_tcx(cx), t) {
2415+
let llsz = llsize_of(type_of(bcx_ccx(cx), cx.sp, t));
2416+
ret call_memmove(cx, dst, src, llsz);
2417+
} else {
2418+
ret rslt(cx, cx.build.Store(cx.build.Load(src), dst));
2419+
}
24152420
}
24162421

24172422
// Duplicates any heap-owned memory owned by a value of the given type.

0 commit comments

Comments
 (0)