Skip to content

Commit 80102c9

Browse files
nikomatsakisbrson
authored andcommitted
avoid extra load for by_mutable_ref parameters
1 parent 7ab6315 commit 80102c9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,8 +3848,7 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38483848

38493849
let r = trans_arg_expr(bcx, ty_arg, llargty, to_zero, to_revoke, arg);
38503850
let llargval = r.val; bcx = r.bcx;
3851-
{ llval: llargval, llty: llargty, static: static,
3852-
by_val: ty_arg.mode == ast::by_val }
3851+
{ llval: llargval, llty: llargty, static: static, mode: ty_arg.mode }
38533852
}, fn_arg_tys, args);
38543853

38553854
// Allocate the argument bundle.
@@ -3865,7 +3864,10 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38653864
if llarg.static {
38663865
// FIXME: This load is unfortunate. It won't be necessary once we
38673866
// have reference types again.
3868-
llargval = llarg.by_val ? llarg.llval : Load(bcx, llarg.llval);
3867+
llargval = alt llarg.mode {
3868+
ast::by_val. | ast::by_mut_ref. { llarg.llval }
3869+
ast::by_ref. | ast::mode_infer. { Load(bcx, llarg.llval) }
3870+
};
38693871
} else {
38703872
llargval = llarg.llval;
38713873
}

src/comp/middle/trans_build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import std::str::sbuf;
33
import lib::llvm::llvm;
44
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, Opcode,
55
ModuleRef};
6-
import trans_common::{block_ctxt, T_ptr, T_nil, T_int, T_i8, T_i1, val_ty};
6+
import trans_common::{block_ctxt, T_ptr, T_nil, T_int, T_i8, T_i1,
7+
val_ty, val_str, bcx_ccx};
78

89
fn B(cx: @block_ctxt) -> BuilderRef {
910
let b = *cx.fcx.lcx.ccx.builder;

0 commit comments

Comments
 (0)