Skip to content

Commit a77e003

Browse files
committed
---
yaml --- r: 5272 b: refs/heads/master c: 6cd2417 h: refs/heads/master v: v3
1 parent 3950f0b commit a77e003

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2aac43d809f913cc1f3c993ea27f5603c73d6627
2+
refs/heads/master: 6cd24173d4e1ad230bc0325901f38f4b336c1652

trunk/src/comp/middle/trans.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,8 @@ fn trans_for_each(cx: @block_ctxt, local: @ast::local, seq: @ast::expr,
27062706
ty::mk_iter_body_fn(lcx.ccx.tcx, decl_ty), 0u);
27072707
let lliterbody: ValueRef =
27082708
decl_internal_fastcall_fn(lcx.ccx.llmod, s, iter_body_llty);
2709-
let fcx = new_fn_ctxt_w_id(lcx, cx.sp, lliterbody, body.node.id);
2709+
let fcx = new_fn_ctxt_w_id(lcx, cx.sp, lliterbody, body.node.id,
2710+
ast::return_val);
27102711
fcx.iterbodyty = cx.fcx.iterbodyty;
27112712

27122713
// Generate code to load the environment out of the
@@ -4383,8 +4384,11 @@ fn trans_ret(cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
43834384
let t = ty::expr_ty(bcx_tcx(cx), x);
43844385
let lv = trans_lval(cx, x);
43854386
bcx = lv.res.bcx;
4386-
let is_local =
4387-
alt x.node {
4387+
if cx.fcx.ret_style == ast::return_ref {
4388+
assert lv.is_mem;
4389+
Store(bcx, cx.fcx.llretptr, lv.res.val);
4390+
} else {
4391+
let is_local = alt x.node {
43884392
ast::expr_path(p) {
43894393
alt bcx_tcx(bcx).def_map.get(x.id) {
43904394
ast::def_local(_) { true }
@@ -4393,9 +4397,12 @@ fn trans_ret(cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
43934397
}
43944398
_ { false }
43954399
};
4396-
if is_local {
4397-
bcx = move_val(bcx, INIT, cx.fcx.llretptr, lv, t);
4398-
} else { bcx = move_val_if_temp(bcx, INIT, cx.fcx.llretptr, lv, t); }
4400+
if is_local {
4401+
bcx = move_val(bcx, INIT, cx.fcx.llretptr, lv, t);
4402+
} else {
4403+
bcx = move_val_if_temp(bcx, INIT, cx.fcx.llretptr, lv, t);
4404+
}
4405+
}
43994406
}
44004407
_ {
44014408
let t = llvm::LLVMGetElementType(val_ty(cx.fcx.llretptr));
@@ -4822,7 +4829,8 @@ fn mk_standard_basic_blocks(llfn: ValueRef) ->
48224829
// - new_fn_ctxt
48234830
// - trans_args
48244831
fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
4825-
id: ast::node_id) -> @fn_ctxt {
4832+
id: ast::node_id, rstyle: ast::ret_style)
4833+
-> @fn_ctxt {
48264834
let llbbs = mk_standard_basic_blocks(llfndecl);
48274835
ret @{llfn: llfndecl,
48284836
lltaskptr: llvm::LLVMGetParam(llfndecl, 1u),
@@ -4845,12 +4853,13 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
48454853
mutable lltydescs: [],
48464854
derived_tydescs: map::mk_hashmap(ty::hash_ty, ty::eq_ty),
48474855
id: id,
4856+
ret_style: rstyle,
48484857
sp: sp,
48494858
lcx: cx};
48504859
}
48514860

48524861
fn new_fn_ctxt(cx: @local_ctxt, sp: span, llfndecl: ValueRef) -> @fn_ctxt {
4853-
be new_fn_ctxt_w_id(cx, sp, llfndecl, -1);
4862+
ret new_fn_ctxt_w_id(cx, sp, llfndecl, -1, ast::return_val);
48544863
}
48554864

48564865
// NB: must keep 4 fns in sync:
@@ -5024,7 +5033,7 @@ fn trans_closure(bcx_maybe: option::t<@block_ctxt>,
50245033
set_uwtable(llfndecl);
50255034

50265035
// Set up arguments to the function.
5027-
let fcx = new_fn_ctxt_w_id(cx, sp, llfndecl, id);
5036+
let fcx = new_fn_ctxt_w_id(cx, sp, llfndecl, id, f.decl.cf);
50285037
create_llargs_for_fn_args(fcx, f.proto, ty_self,
50295038
ty::ret_ty_of_fn(cx.ccx.tcx, id), f.decl.inputs,
50305039
ty_params);

trunk/src/comp/middle/trans_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ type fn_ctxt =
261261
mutable lltydescs: [ValueRef],
262262
derived_tydescs: hashmap<ty::t, derived_tydesc_info>,
263263
id: ast::node_id,
264+
ret_style: ast::ret_style,
264265
sp: span,
265266
lcx: @local_ctxt};
266267

0 commit comments

Comments
 (0)