Skip to content

Commit 5472d22

Browse files
committed
Merge remote-tracking branch 'graydon/master' into snap
2 parents 8b9a78e + 5917d80 commit 5472d22

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

src/comp/middle/trans.rs

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ fn make_take_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t) {
13121312
bcx = incr_refcnt_of_boxed(cx, bld::Load(cx, v)).bcx;
13131313
} else if ty::type_is_structural(bcx_tcx(cx), t) {
13141314
bcx = duplicate_heap_parts_if_necessary(cx, v, t).bcx;
1315-
bcx = iter_structural_ty(bcx, v, t, bind take_ty(_, _, _)).bcx;
1315+
bcx = iter_structural_ty(bcx, v, t, take_ty).bcx;
13161316
} else { bcx = cx; }
13171317

13181318
build_return(bcx);
@@ -1349,8 +1349,7 @@ fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) {
13491349
let body =
13501350
bld::GEP(cx, v, [C_int(0), C_int(abi::box_rc_field_body)]);
13511351
let body_ty = body_mt.ty;
1352-
let body_val = load_if_immediate(cx, body, body_ty);
1353-
let rs = drop_ty(cx, body_val, body_ty);
1352+
let rs = drop_ty(cx, body, body_ty);
13541353
if !bcx_ccx(cx).sess.get_opts().do_gc {
13551354
trans_non_gc_free(rs.bcx, v)
13561355
} else { rslt(cx, C_nil()) }
@@ -1469,7 +1468,7 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) {
14691468
_ {
14701469
if ty::type_has_pointers(ccx.tcx, t) &&
14711470
ty::type_is_structural(ccx.tcx, t) {
1472-
iter_structural_ty(cx, v0, t, bind drop_ty(_, _, _))
1471+
iter_structural_ty(cx, v0, t, drop_ty)
14731472
} else { rslt(cx, C_nil()) }
14741473
}
14751474
};
@@ -1518,7 +1517,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
15181517
let val_cast = bld::BitCast(cx, val.val, val_llty);
15191518
bld::FastCall(cx, dtor_addr, args + [val_cast]);
15201519

1521-
cx = drop_slot(cx, val.val, inner_t_s).bcx;
1520+
cx = drop_ty(cx, val.val, inner_t_s).bcx;
15221521
bld::Store(cx, C_int(0), drop_flag.val);
15231522
bld::Br(cx, next_cx.llbb);
15241523
ret rslt(next_cx, C_nil());
@@ -1549,7 +1548,7 @@ fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef,
15491548
let zero_test = bld::ICmp(rc_adj_cx, lib::llvm::LLVMIntEQ, C_int(0), rc);
15501549
bld::CondBr(rc_adj_cx, zero_test, free_cx.llbb, next_cx.llbb);
15511550
let free_res =
1552-
free_ty(free_cx, load_if_immediate(free_cx, full_alias, t), t);
1551+
free_ty(free_cx, full_alias, t);
15531552
bld::Br(free_res.bcx, next_cx.llbb);
15541553
let t_else = T_nil();
15551554
let v_else = C_nil();
@@ -1728,7 +1727,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
17281727
let next_cx = new_sub_block_ctxt(cx, "next");
17291728
let null_test = bld::IsNull(cx, box_ptr);
17301729
bld::CondBr(cx, null_test, next_cx.llbb, inner_cx.llbb);
1731-
let r = f(inner_cx, box_ptr, tbox);
1730+
let r = f(inner_cx, box_cell, tbox);
17321731
bld::Br(r.bcx, next_cx.llbb);
17331732
ret rslt(next_cx, C_nil());
17341733
}
@@ -1772,9 +1771,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
17721771
bld::CondBr(loop_header_cx, not_yet_at_end, loop_body_cx.llbb,
17731772
next_cx.llbb);
17741773

1775-
rs =
1776-
f(loop_body_cx,
1777-
load_if_immediate(loop_body_cx, dest_elem, unit_ty), unit_ty);
1774+
rs = f(loop_body_cx, dest_elem, unit_ty);
17781775

17791776
loop_body_cx = rs.bcx;
17801777

@@ -1805,8 +1802,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18051802
let llfldp_a = rslt.val;
18061803
cx = rslt.bcx;
18071804
let ty_subst = ty::substitute_type_params(ccx.tcx, tps, a.ty);
1808-
let llfld_a = load_if_immediate(cx, llfldp_a, ty_subst);
1809-
rslt = f(cx, llfld_a, ty_subst);
1805+
rslt = f(cx, llfldp_a, ty_subst);
18101806
cx = rslt.bcx;
18111807
j += 1;
18121808
}
@@ -1822,9 +1818,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18221818
for fld: ty::field in fields {
18231819
r = GEP_tup_like(r.bcx, t, av, [0, i]);
18241820
let llfld_a = r.val;
1825-
r =
1826-
f(r.bcx, load_if_immediate(r.bcx, llfld_a, fld.mt.ty),
1827-
fld.mt.ty);
1821+
r = f(r.bcx, llfld_a, fld.mt.ty);
18281822
i += 1;
18291823
}
18301824
}
@@ -1833,7 +1827,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18331827
for arg in args {
18341828
r = GEP_tup_like(r.bcx, t, av, [0, i]);
18351829
let llfld_a = r.val;
1836-
r = f(r.bcx, load_if_immediate(r.bcx, llfld_a, arg), arg);
1830+
r = f(r.bcx, llfld_a, arg);
18371831
i += 1;
18381832
}
18391833
}
@@ -1844,7 +1838,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18441838
let tup_t = ty::mk_tup(tcx, [ty::mk_int(tcx), inner_t_s]);
18451839
r = GEP_tup_like(r.bcx, tup_t, av, [0, 1]);
18461840
let llfld_a = r.val;
1847-
r = f(r.bcx, load_if_immediate(r.bcx, llfld_a, inner1), inner1);
1841+
r = f(r.bcx, llfld_a, inner1);
18481842
}
18491843
ty::ty_tag(tid, tps) {
18501844
let variants = ty::tag_variants(bcx_tcx(cx), tid);
@@ -1864,7 +1858,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18641858
// NB: we must hit the discriminant first so that structural
18651859
// comparison know not to proceed when the discriminants differ.
18661860
let bcx = cx;
1867-
bcx = f(bcx, lldiscrim_a, ty::mk_int(bcx_tcx(cx))).bcx;
1861+
bcx = f(bcx, lldiscrim_a_ptr, ty::mk_int(bcx_tcx(cx))).bcx;
18681862
let unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
18691863
bld::Unreachable(unr_cx);
18701864
let llswitch = bld::Switch(bcx, lldiscrim_a, unr_cx.llbb, n_variants);
@@ -2141,7 +2135,7 @@ fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef,
21412135
}
21422136
}
21432137

2144-
let llrawptr = bld::BitCast(cx, v, T_ptr(T_i8()));
2138+
let llrawptr = bld::PointerCast(cx, v, T_ptr(T_i8()));
21452139
let lltydescs =
21462140
bld::GEP(cx, tydesc,
21472141
[C_int(0), C_int(abi::tydesc_field_first_param)]);
@@ -2165,8 +2159,7 @@ fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t, field: int) ->
21652159
result {
21662160
let ti: option::t<@tydesc_info> = none::<@tydesc_info>;
21672161
let td = get_tydesc(cx, t, false, tps_normal, ti).result;
2168-
call_tydesc_glue_full(td.bcx, spill_if_immediate(td.bcx, v, t), td.val,
2169-
field, ti);
2162+
call_tydesc_glue_full(td.bcx, v, td.val, field, ti);
21702163
ret rslt(td.bcx, C_nil());
21712164
}
21722165

@@ -2266,11 +2259,6 @@ fn take_ty(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> result {
22662259
ret rslt(cx, C_nil());
22672260
}
22682261

2269-
fn drop_slot(cx: &@block_ctxt, slot: ValueRef, t: ty::t) -> result {
2270-
let llptr = load_if_immediate(cx, slot, t);
2271-
ret drop_ty(cx, llptr, t);
2272-
}
2273-
22742262
fn drop_ty(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> result {
22752263
if ty::type_needs_drop(bcx_tcx(cx), t) {
22762264
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue);
@@ -2392,10 +2380,10 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef,
23922380
ret cx;
23932381
} else if ty::type_is_boxed(ccx.tcx, t) {
23942382
let bcx = if action == DROP_EXISTING {
2395-
drop_ty(cx, bld::Load(cx, dst), t).bcx
2383+
drop_ty(cx, dst, t).bcx
23962384
} else { cx };
2397-
bcx = take_ty(bcx, src, t).bcx;
23982385
bld::Store(bcx, src, dst);
2386+
bcx = take_ty(bcx, dst, t).bcx;
23992387
ret bcx;
24002388
} else if type_is_structural_or_param(ccx.tcx, t) {
24012389
let bcx = if action == DROP_EXISTING {
@@ -2433,7 +2421,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
24332421
ty::type_is_boxed(tcx, t) {
24342422
if src.is_mem { src_val = bld::Load(cx, src_val); }
24352423
if action == DROP_EXISTING {
2436-
cx = drop_ty(cx, bld::Load(cx, dst), t).bcx;
2424+
cx = drop_ty(cx, dst, t).bcx;
24372425
}
24382426
bld::Store(cx, src_val, dst);
24392427
if src.is_mem { ret zero_alloca(cx, src.res.val, t).bcx; }
@@ -3963,9 +3951,12 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef,
39633951
add_clean_temp(bcx, val, e_ty);
39643952
} else {
39653953
if lv.is_mem {
3954+
bcx = take_ty(bcx, val, e_ty).bcx;
39663955
val = load_if_immediate(bcx, val, e_ty);
3956+
} else if is_ext_vec_plus {
3957+
let spilled = do_spill(bcx, val);
3958+
bcx = take_ty(bcx, spilled, e_ty).bcx;
39673959
}
3968-
bcx = take_ty(bcx, val, e_ty).bcx;
39693960
add_clean_temp(bcx, val, e_ty);
39703961
}
39713962
} else if type_is_immediate(ccx, e_ty) && !lv.is_mem {
@@ -4481,11 +4472,6 @@ fn with_out_method(work: fn(&out_method) -> result, cx: @block_ctxt,
44814472
if ty::type_is_nil(ccx.tcx, tp) { ret work(return); }
44824473
let res_alloca = alloc_ty(cx, tp);
44834474
cx = zero_alloca(res_alloca.bcx, res_alloca.val, tp).bcx;
4484-
fn drop_hoisted_ty(cx: &@block_ctxt, target: ValueRef, t: ty::t) ->
4485-
result {
4486-
let reg_val = load_if_immediate(cx, target, t);
4487-
ret drop_ty(cx, reg_val, t);
4488-
}
44894475
let done = work(save_in(res_alloca.val));
44904476
let loaded = load_if_immediate(done.bcx, res_alloca.val, tp);
44914477
add_clean_temp(cx, loaded, tp);
@@ -5274,7 +5260,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, scope: @block_ctxt,
52745260
// Args that are locally assigned to need to do a local
52755261
// take/drop
52765262
if fcx.lcx.ccx.mut_map.contains_key(aarg.id) {
5277-
bcx = take_ty(bcx, aval, arg_ty).bcx;
5263+
bcx = take_ty(bcx, addr, arg_ty).bcx;
52785264
add_clean(scope, addr, arg_ty);
52795265
}
52805266
}

src/comp/middle/trans_common.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import bld = trans_build;
5959

6060
// FIXME: These should probably be pulled in here too.
6161
import trans::type_of_fn_full;
62-
import trans::drop_slot;
6362
import trans::drop_ty;
6463

6564
obj namegen(mutable i: int) {
@@ -299,10 +298,15 @@ tag cleanup {
299298
}
300299

301300
fn add_clean(cx: &@block_ctxt, val: ValueRef, ty: ty::t) {
302-
find_scope_cx(cx).cleanups += [clean(bind drop_slot(_, val, ty))];
301+
find_scope_cx(cx).cleanups += [clean(bind drop_ty(_, val, ty))];
303302
}
304303
fn add_clean_temp(cx: &@block_ctxt, val: ValueRef, ty: ty::t) {
305-
find_scope_cx(cx).cleanups += [clean_temp(val, bind drop_ty(_, val, ty))];
304+
fn spill_and_drop(bcx: &@block_ctxt, val: ValueRef, ty: ty::t) -> result {
305+
let spilled = trans::spill_if_immediate(bcx, val, ty);
306+
ret drop_ty(bcx, spilled, ty);
307+
}
308+
find_scope_cx(cx).cleanups +=
309+
[clean_temp(val, bind spill_and_drop(_, val, ty))];
306310
}
307311

308312
// Note that this only works for temporaries. We should, at some point, move

0 commit comments

Comments
 (0)