mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
auto merge of #12014 : eddyb/rust/less-copies, r=cmr
This commit is contained in:
commit
28f277b909
@ -2028,9 +2028,21 @@ pub fn store_arg<'a>(mut bcx: &'a Block<'a>,
|
||||
Some(path) => {
|
||||
// Generate nicer LLVM for the common case of fn a pattern
|
||||
// like `x: T`
|
||||
mk_binding_alloca(
|
||||
bcx, pat.id, path, BindArgument, arg_scope, arg,
|
||||
|arg, bcx, llval, _| arg.store_to(bcx, llval))
|
||||
let arg_ty = node_id_type(bcx, pat.id);
|
||||
if type_of::arg_is_indirect(bcx.ccx(), arg_ty)
|
||||
&& !bcx.ccx().sess.opts.extra_debuginfo {
|
||||
// Don't copy an indirect argument to an alloca, the caller
|
||||
// already put it in a temporary alloca and gave it up, unless
|
||||
// we emit extra-debug-info, which requires local allocas :(.
|
||||
let arg_val = arg.add_clean(bcx.fcx, arg_scope);
|
||||
let mut llmap = bcx.fcx.llargs.borrow_mut();
|
||||
llmap.get().insert(pat.id, Datum(arg_val, arg_ty, Lvalue));
|
||||
bcx
|
||||
} else {
|
||||
mk_binding_alloca(
|
||||
bcx, pat.id, path, BindArgument, arg_scope, arg,
|
||||
|arg, bcx, llval, _| arg.store_to(bcx, llval))
|
||||
}
|
||||
}
|
||||
|
||||
None => {
|
||||
|
Loading…
Reference in New Issue
Block a user