Skip to content

Commit 7c37d37

Browse files
committed
---
yaml --- r: 4949 b: refs/heads/master c: 8b9a78e h: refs/heads/master i: 4947: b5b9165 v: v3
1 parent 5505ba2 commit 7c37d37

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5917d80cd7dc83a87228a17e2c04dab8f53f06d3
2+
refs/heads/master: 8b9a78e8c48eda153fe49e62c94465bb1bd3ffb8

trunk/src/comp/middle/trans.rs

Lines changed: 36 additions & 22 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, take_ty).bcx;
1315+
bcx = iter_structural_ty(bcx, v, t, bind take_ty(_, _, _)).bcx;
13161316
} else { bcx = cx; }
13171317

13181318
build_return(bcx);
@@ -1349,7 +1349,8 @@ 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 rs = drop_ty(cx, body, body_ty);
1352+
let body_val = load_if_immediate(cx, body, body_ty);
1353+
let rs = drop_ty(cx, body_val, body_ty);
13531354
if !bcx_ccx(cx).sess.get_opts().do_gc {
13541355
trans_non_gc_free(rs.bcx, v)
13551356
} else { rslt(cx, C_nil()) }
@@ -1468,7 +1469,7 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) {
14681469
_ {
14691470
if ty::type_has_pointers(ccx.tcx, t) &&
14701471
ty::type_is_structural(ccx.tcx, t) {
1471-
iter_structural_ty(cx, v0, t, drop_ty)
1472+
iter_structural_ty(cx, v0, t, bind drop_ty(_, _, _))
14721473
} else { rslt(cx, C_nil()) }
14731474
}
14741475
};
@@ -1517,7 +1518,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
15171518
let val_cast = bld::BitCast(cx, val.val, val_llty);
15181519
bld::FastCall(cx, dtor_addr, args + [val_cast]);
15191520

1520-
cx = drop_ty(cx, val.val, inner_t_s).bcx;
1521+
cx = drop_slot(cx, val.val, inner_t_s).bcx;
15211522
bld::Store(cx, C_int(0), drop_flag.val);
15221523
bld::Br(cx, next_cx.llbb);
15231524
ret rslt(next_cx, C_nil());
@@ -1548,7 +1549,7 @@ fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef,
15481549
let zero_test = bld::ICmp(rc_adj_cx, lib::llvm::LLVMIntEQ, C_int(0), rc);
15491550
bld::CondBr(rc_adj_cx, zero_test, free_cx.llbb, next_cx.llbb);
15501551
let free_res =
1551-
free_ty(free_cx, full_alias, t);
1552+
free_ty(free_cx, load_if_immediate(free_cx, full_alias, t), t);
15521553
bld::Br(free_res.bcx, next_cx.llbb);
15531554
let t_else = T_nil();
15541555
let v_else = C_nil();
@@ -1727,7 +1728,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
17271728
let next_cx = new_sub_block_ctxt(cx, "next");
17281729
let null_test = bld::IsNull(cx, box_ptr);
17291730
bld::CondBr(cx, null_test, next_cx.llbb, inner_cx.llbb);
1730-
let r = f(inner_cx, box_cell, tbox);
1731+
let r = f(inner_cx, box_ptr, tbox);
17311732
bld::Br(r.bcx, next_cx.llbb);
17321733
ret rslt(next_cx, C_nil());
17331734
}
@@ -1771,7 +1772,9 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
17711772
bld::CondBr(loop_header_cx, not_yet_at_end, loop_body_cx.llbb,
17721773
next_cx.llbb);
17731774

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

17761779
loop_body_cx = rs.bcx;
17771780

@@ -1802,7 +1805,8 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18021805
let llfldp_a = rslt.val;
18031806
cx = rslt.bcx;
18041807
let ty_subst = ty::substitute_type_params(ccx.tcx, tps, a.ty);
1805-
rslt = f(cx, llfldp_a, ty_subst);
1808+
let llfld_a = load_if_immediate(cx, llfldp_a, ty_subst);
1809+
rslt = f(cx, llfld_a, ty_subst);
18061810
cx = rslt.bcx;
18071811
j += 1;
18081812
}
@@ -1818,7 +1822,9 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18181822
for fld: ty::field in fields {
18191823
r = GEP_tup_like(r.bcx, t, av, [0, i]);
18201824
let llfld_a = r.val;
1821-
r = f(r.bcx, llfld_a, fld.mt.ty);
1825+
r =
1826+
f(r.bcx, load_if_immediate(r.bcx, llfld_a, fld.mt.ty),
1827+
fld.mt.ty);
18221828
i += 1;
18231829
}
18241830
}
@@ -1827,7 +1833,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18271833
for arg in args {
18281834
r = GEP_tup_like(r.bcx, t, av, [0, i]);
18291835
let llfld_a = r.val;
1830-
r = f(r.bcx, llfld_a, arg);
1836+
r = f(r.bcx, load_if_immediate(r.bcx, llfld_a, arg), arg);
18311837
i += 1;
18321838
}
18331839
}
@@ -1838,7 +1844,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18381844
let tup_t = ty::mk_tup(tcx, [ty::mk_int(tcx), inner_t_s]);
18391845
r = GEP_tup_like(r.bcx, tup_t, av, [0, 1]);
18401846
let llfld_a = r.val;
1841-
r = f(r.bcx, llfld_a, inner1);
1847+
r = f(r.bcx, load_if_immediate(r.bcx, llfld_a, inner1), inner1);
18421848
}
18431849
ty::ty_tag(tid, tps) {
18441850
let variants = ty::tag_variants(bcx_tcx(cx), tid);
@@ -1858,7 +1864,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t,
18581864
// NB: we must hit the discriminant first so that structural
18591865
// comparison know not to proceed when the discriminants differ.
18601866
let bcx = cx;
1861-
bcx = f(bcx, lldiscrim_a_ptr, ty::mk_int(bcx_tcx(cx))).bcx;
1867+
bcx = f(bcx, lldiscrim_a, ty::mk_int(bcx_tcx(cx))).bcx;
18621868
let unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
18631869
bld::Unreachable(unr_cx);
18641870
let llswitch = bld::Switch(bcx, lldiscrim_a, unr_cx.llbb, n_variants);
@@ -2135,7 +2141,7 @@ fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef,
21352141
}
21362142
}
21372143

2138-
let llrawptr = bld::PointerCast(cx, v, T_ptr(T_i8()));
2144+
let llrawptr = bld::BitCast(cx, v, T_ptr(T_i8()));
21392145
let lltydescs =
21402146
bld::GEP(cx, tydesc,
21412147
[C_int(0), C_int(abi::tydesc_field_first_param)]);
@@ -2159,7 +2165,8 @@ fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t, field: int) ->
21592165
result {
21602166
let ti: option::t<@tydesc_info> = none::<@tydesc_info>;
21612167
let td = get_tydesc(cx, t, false, tps_normal, ti).result;
2162-
call_tydesc_glue_full(td.bcx, v, td.val, field, ti);
2168+
call_tydesc_glue_full(td.bcx, spill_if_immediate(td.bcx, v, t), td.val,
2169+
field, ti);
21632170
ret rslt(td.bcx, C_nil());
21642171
}
21652172

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

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+
22622274
fn drop_ty(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> result {
22632275
if ty::type_needs_drop(bcx_tcx(cx), t) {
22642276
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue);
@@ -2380,10 +2392,10 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef,
23802392
ret cx;
23812393
} else if ty::type_is_boxed(ccx.tcx, t) {
23822394
let bcx = if action == DROP_EXISTING {
2383-
drop_ty(cx, dst, t).bcx
2395+
drop_ty(cx, bld::Load(cx, dst), t).bcx
23842396
} else { cx };
2397+
bcx = take_ty(bcx, src, t).bcx;
23852398
bld::Store(bcx, src, dst);
2386-
bcx = take_ty(bcx, dst, t).bcx;
23872399
ret bcx;
23882400
} else if type_is_structural_or_param(ccx.tcx, t) {
23892401
let bcx = if action == DROP_EXISTING {
@@ -2421,7 +2433,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
24212433
ty::type_is_boxed(tcx, t) {
24222434
if src.is_mem { src_val = bld::Load(cx, src_val); }
24232435
if action == DROP_EXISTING {
2424-
cx = drop_ty(cx, dst, t).bcx;
2436+
cx = drop_ty(cx, bld::Load(cx, dst), t).bcx;
24252437
}
24262438
bld::Store(cx, src_val, dst);
24272439
if src.is_mem { ret zero_alloca(cx, src.res.val, t).bcx; }
@@ -3951,12 +3963,9 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef,
39513963
add_clean_temp(bcx, val, e_ty);
39523964
} else {
39533965
if lv.is_mem {
3954-
bcx = take_ty(bcx, val, e_ty).bcx;
39553966
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;
39593967
}
3968+
bcx = take_ty(bcx, val, e_ty).bcx;
39603969
add_clean_temp(bcx, val, e_ty);
39613970
}
39623971
} else if type_is_immediate(ccx, e_ty) && !lv.is_mem {
@@ -4472,6 +4481,11 @@ fn with_out_method(work: fn(&out_method) -> result, cx: @block_ctxt,
44724481
if ty::type_is_nil(ccx.tcx, tp) { ret work(return); }
44734482
let res_alloca = alloc_ty(cx, tp);
44744483
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+
}
44754489
let done = work(save_in(res_alloca.val));
44764490
let loaded = load_if_immediate(done.bcx, res_alloca.val, tp);
44774491
add_clean_temp(cx, loaded, tp);
@@ -5260,7 +5274,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, scope: @block_ctxt,
52605274
// Args that are locally assigned to need to do a local
52615275
// take/drop
52625276
if fcx.lcx.ccx.mut_map.contains_key(aarg.id) {
5263-
bcx = take_ty(bcx, addr, arg_ty).bcx;
5277+
bcx = take_ty(bcx, aval, arg_ty).bcx;
52645278
add_clean(scope, addr, arg_ty);
52655279
}
52665280
}

trunk/src/comp/middle/trans_common.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ 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;
6263
import trans::drop_ty;
6364

6465
obj namegen(mutable i: int) {
@@ -298,15 +299,10 @@ tag cleanup {
298299
}
299300

300301
fn add_clean(cx: &@block_ctxt, val: ValueRef, ty: ty::t) {
301-
find_scope_cx(cx).cleanups += [clean(bind drop_ty(_, val, ty))];
302+
find_scope_cx(cx).cleanups += [clean(bind drop_slot(_, val, ty))];
302303
}
303304
fn add_clean_temp(cx: &@block_ctxt, val: ValueRef, ty: ty::t) {
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))];
305+
find_scope_cx(cx).cleanups += [clean_temp(val, bind drop_ty(_, val, ty))];
310306
}
311307

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

trunk/src/snapshots.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
S 2011-08-26 844e2d7
2+
linux-i386 a896a6fe1bfbf38fac66db71edfa3750871edd55
3+
macos-i386 d8d5c6144870389d9c233684576ac7b816e82655
4+
winnt-i386 570d7515403f9bd5afa41e98f027ceedba88d588
5+
16
S 2011-08-25 e241f29
27
linux-i386 af777f99bf51da80f24c53092773546868b27d02
38
macos-i386 5f460da5988e469ced04670dc4bcfb9b95128717

0 commit comments

Comments
 (0)