avoid extra load for by_mutable_ref parameters

This commit is contained in:
Niko Matsakis 2011-10-17 20:46:03 -07:00 committed by Brian Anderson
parent 7ab6315f5f
commit 80102c9d24
2 changed files with 7 additions and 4 deletions

View File

@ -3848,8 +3848,7 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
let r = trans_arg_expr(bcx, ty_arg, llargty, to_zero, to_revoke, arg);
let llargval = r.val; bcx = r.bcx;
{ llval: llargval, llty: llargty, static: static,
by_val: ty_arg.mode == ast::by_val }
{ llval: llargval, llty: llargty, static: static, mode: ty_arg.mode }
}, fn_arg_tys, args);
// Allocate the argument bundle.
@ -3865,7 +3864,10 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
if llarg.static {
// FIXME: This load is unfortunate. It won't be necessary once we
// have reference types again.
llargval = llarg.by_val ? llarg.llval : Load(bcx, llarg.llval);
llargval = alt llarg.mode {
ast::by_val. | ast::by_mut_ref. { llarg.llval }
ast::by_ref. | ast::mode_infer. { Load(bcx, llarg.llval) }
};
} else {
llargval = llarg.llval;
}

View File

@ -3,7 +3,8 @@ import std::str::sbuf;
import lib::llvm::llvm;
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, Opcode,
ModuleRef};
import trans_common::{block_ctxt, T_ptr, T_nil, T_int, T_i8, T_i1, val_ty};
import trans_common::{block_ctxt, T_ptr, T_nil, T_int, T_i8, T_i1,
val_ty, val_str, bcx_ccx};
fn B(cx: @block_ctxt) -> BuilderRef {
let b = *cx.fcx.lcx.ccx.builder;