aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-03 18:43:00 -0800
committerGraydon Hoare <[email protected]>2010-12-03 18:43:40 -0800
commit9f6a6305196cff86a93d56718cd22edd6b87aa9e (patch)
tree7a699669ba6d65f650e64247360fd6c1dcb06f2b /src
parentrustc: Make new_fn_ctxt and copy_args_to_allocas receive a list of args rathe... (diff)
downloadrust-9f6a6305196cff86a93d56718cd22edd6b87aa9e.tar.xz
rust-9f6a6305196cff86a93d56718cd22edd6b87aa9e.zip
Drop rec and tup alloca temporariles on block exit.
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 9b94526b..64cba812 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -708,7 +708,9 @@ fn iter_sequence(@block_ctxt cx,
cond_cx.build.CondBr(end_test, body_cx.llbb, next_cx.llbb);
auto elt = body_cx.build.GEP(p0, vec(ix));
- auto body_res = f(body_cx, elt, elt_ty);
+ auto body_res = f(body_cx,
+ load_non_structural(body_cx, elt, elt_ty),
+ elt_ty);
auto next_ix = body_res.bcx.build.Add(ix, C_int(1));
cond_cx.build.AddIncomingToPhi(ix, vec(next_ix),
vec(body_res.bcx.llbb));
@@ -751,11 +753,7 @@ fn incr_all_refcnts(@block_ctxt cx,
fn drop_slot(@block_ctxt cx,
ValueRef slot,
@typeck.ty t) -> result {
- if (typeck.type_is_structural(t)) {
- be drop_ty(cx, slot, t);
- } else {
- be drop_ty(cx, cx.build.Load(slot), t);
- }
+ be drop_ty(cx, load_non_structural(cx, slot, t), t);
}
fn drop_ty(@block_ctxt cx,
@@ -955,8 +953,7 @@ fn target_type(@crate_ctxt cx, @typeck.ty t) -> @typeck.ty {
fn node_ann_type(@crate_ctxt cx, &ast.ann a) -> @typeck.ty {
alt (a) {
case (ast.ann_none) {
- log "missing type annotation";
- fail;
+ cx.sess.bug("missing type annotation");
}
case (ast.ann_type(?t)) {
ret target_type(cx, t);
@@ -1412,8 +1409,10 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f,
impure fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
&ast.ann ann) -> result {
- auto ty = node_type(cx.fcx.ccx, ann);
- auto tup_val = cx.build.Alloca(ty);
+ auto ty = node_ann_type(cx.fcx.ccx, ann);
+ auto llty = type_of(cx.fcx.ccx, ty);
+ auto tup_val = cx.build.Alloca(llty);
+ find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tup_val, ty));
let int i = 0;
auto r = res(cx, C_nil());
for (ast.elt e in elts) {
@@ -1429,8 +1428,10 @@ impure fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
impure fn trans_rec(@block_ctxt cx, vec[ast.field] fields,
&ast.ann ann) -> result {
- auto ty = node_type(cx.fcx.ccx, ann);
- auto rec_val = cx.build.Alloca(ty);
+ auto ty = node_ann_type(cx.fcx.ccx, ann);
+ auto llty = type_of(cx.fcx.ccx, ty);
+ auto rec_val = cx.build.Alloca(llty);
+ find_scope_cx(cx).cleanups += clean(bind drop_ty(_, rec_val, ty));
let int i = 0;
auto r = res(cx, C_nil());
for (ast.field f in fields) {