rustc: Use memmove in unsafe::reinterpret_cast (issue #3025).
This was causing a bunch of structural copies, which when inlined was leading to enormous register pressure. Often this is seen in code which makes use of result::unwrap.
This commit is contained in:
parent
ff9151fa55
commit
62be878ed1
1 changed files with 6 additions and 3 deletions
|
@ -937,9 +937,12 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||||
ty_to_str(ccx.tcx, substs.tys[1]), out_sz));
|
ty_to_str(ccx.tcx, substs.tys[1]), out_sz));
|
||||||
}
|
}
|
||||||
if !ty::type_is_nil(substs.tys[1]) {
|
if !ty::type_is_nil(substs.tys[1]) {
|
||||||
let cast = PointerCast(bcx, get_param(decl, first_real_arg),
|
// NB: Do not use a Load and Store here. This causes massive code
|
||||||
T_ptr(llout_ty));
|
// bloat when reinterpret_cast is used on large structural types.
|
||||||
Store(bcx, Load(bcx, cast), fcx.llretptr);
|
let llretptr = PointerCast(bcx, fcx.llretptr, T_ptr(T_i8()));
|
||||||
|
let llcast = get_param(decl, first_real_arg);
|
||||||
|
let llcast = PointerCast(bcx, llcast, T_ptr(T_i8()));
|
||||||
|
call_memmove(bcx, llretptr, llcast, llsize_of(ccx, lltp_ty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~"addr_of" => {
|
~"addr_of" => {
|
||||||
|
|
Loading…
Reference in a new issue