Skip to content

Don't copy arguments passed by value with indirection to allocas. #12014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down