提交 62be878e 编写于 作者: P Patrick Walton

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.
上级 ff9151fa
......@@ -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));
}
if !ty::type_is_nil(substs.tys[1]) {
let cast = PointerCast(bcx, get_param(decl, first_real_arg),
T_ptr(llout_ty));
Store(bcx, Load(bcx, cast), fcx.llretptr);
// NB: Do not use a Load and Store here. This causes massive code
// bloat when reinterpret_cast is used on large structural types.
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" => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册