Skip to content

Commit 9f6a630

Browse files
committed
Drop rec and tup alloca temporariles on block exit.
1 parent b4d9754 commit 9f6a630

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/comp/middle/trans.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ fn iter_sequence(@block_ctxt cx,
708708
cond_cx.build.CondBr(end_test, body_cx.llbb, next_cx.llbb);
709709

710710
auto elt = body_cx.build.GEP(p0, vec(ix));
711-
auto body_res = f(body_cx, elt, elt_ty);
711+
auto body_res = f(body_cx,
712+
load_non_structural(body_cx, elt, elt_ty),
713+
elt_ty);
712714
auto next_ix = body_res.bcx.build.Add(ix, C_int(1));
713715
cond_cx.build.AddIncomingToPhi(ix, vec(next_ix),
714716
vec(body_res.bcx.llbb));
@@ -751,11 +753,7 @@ fn incr_all_refcnts(@block_ctxt cx,
751753
fn drop_slot(@block_ctxt cx,
752754
ValueRef slot,
753755
@typeck.ty t) -> result {
754-
if (typeck.type_is_structural(t)) {
755-
be drop_ty(cx, slot, t);
756-
} else {
757-
be drop_ty(cx, cx.build.Load(slot), t);
758-
}
756+
be drop_ty(cx, load_non_structural(cx, slot, t), t);
759757
}
760758

761759
fn drop_ty(@block_ctxt cx,
@@ -955,8 +953,7 @@ fn target_type(@crate_ctxt cx, @typeck.ty t) -> @typeck.ty {
955953
fn node_ann_type(@crate_ctxt cx, &ast.ann a) -> @typeck.ty {
956954
alt (a) {
957955
case (ast.ann_none) {
958-
log "missing type annotation";
959-
fail;
956+
cx.sess.bug("missing type annotation");
960957
}
961958
case (ast.ann_type(?t)) {
962959
ret target_type(cx, t);
@@ -1412,8 +1409,10 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f,
14121409

14131410
impure fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
14141411
&ast.ann ann) -> result {
1415-
auto ty = node_type(cx.fcx.ccx, ann);
1416-
auto tup_val = cx.build.Alloca(ty);
1412+
auto ty = node_ann_type(cx.fcx.ccx, ann);
1413+
auto llty = type_of(cx.fcx.ccx, ty);
1414+
auto tup_val = cx.build.Alloca(llty);
1415+
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tup_val, ty));
14171416
let int i = 0;
14181417
auto r = res(cx, C_nil());
14191418
for (ast.elt e in elts) {
@@ -1429,8 +1428,10 @@ impure fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
14291428

14301429
impure fn trans_rec(@block_ctxt cx, vec[ast.field] fields,
14311430
&ast.ann ann) -> result {
1432-
auto ty = node_type(cx.fcx.ccx, ann);
1433-
auto rec_val = cx.build.Alloca(ty);
1431+
auto ty = node_ann_type(cx.fcx.ccx, ann);
1432+
auto llty = type_of(cx.fcx.ccx, ty);
1433+
auto rec_val = cx.build.Alloca(llty);
1434+
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, rec_val, ty));
14341435
let int i = 0;
14351436
auto r = res(cx, C_nil());
14361437
for (ast.field f in fields) {

0 commit comments

Comments
 (0)