diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index a103c7d311b..09967f9034a 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3739,11 +3739,11 @@ fn invoke_(bcx: @block_ctxt, llfn: ValueRef, fn get_landing_pad(bcx: @block_ctxt) -> BasicBlockRef { let scope_bcx = find_scope_cx(bcx); - if scope_bcx.cleanups_dirty { + if scope_bcx.need_new_lpad { let unwind_bcx = new_sub_block_ctxt(bcx, "unwind"); let lpadbb = trans_landing_pad(unwind_bcx); scope_bcx.lpad = some(lpadbb); - scope_bcx.cleanups_dirty = false; + scope_bcx.need_new_lpad = false; } assert option::is_some(scope_bcx.lpad); ret option::get(scope_bcx.lpad); @@ -4533,7 +4533,7 @@ fn new_block_ctxt(cx: @fn_ctxt, parent: block_parent, kind: block_kind, parent: parent, kind: kind, mutable cleanups: [], - mutable cleanups_dirty: true, + mutable need_new_lpad: true, mutable lpad: option::none, sp: cx.sp, fcx: cx}; @@ -4569,7 +4569,7 @@ fn new_raw_block_ctxt(fcx: @fn_ctxt, llbb: BasicBlockRef) -> @block_ctxt { parent: parent_none, kind: NON_SCOPE_BLOCK, mutable cleanups: [], - mutable cleanups_dirty: true, + mutable need_new_lpad: true, mutable lpad: option::none, sp: fcx.sp, fcx: fcx}; @@ -4637,7 +4637,7 @@ fn llstaticallocas_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt { parent: parent_none, kind: SCOPE_BLOCK, mutable cleanups: [], - mutable cleanups_dirty: true, + mutable need_new_lpad: true, mutable lpad: option::none, sp: fcx.sp, fcx: fcx}; @@ -4649,7 +4649,7 @@ fn llderivedtydescs_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt { parent: parent_none, kind: SCOPE_BLOCK, mutable cleanups: [], - mutable cleanups_dirty: true, + mutable need_new_lpad: true, mutable lpad: option::none, sp: fcx.sp, fcx: fcx}; diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index a02f51d7770..d4a6ddc9b72 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -272,7 +272,6 @@ tag cleanup { fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) { let scope_cx = find_scope_cx(cx); scope_cx.cleanups += [clean(bind drop_ty(_, val, ty))]; - scope_cx.cleanups_dirty = true; } fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) { fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) -> @@ -286,7 +285,9 @@ fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) { let scope_cx = find_scope_cx(cx); scope_cx.cleanups += [clean_temp(val, bind spill_and_drop(_, val, ty))]; - scope_cx.cleanups_dirty = true; + if trans::type_is_immediate(bcx_ccx(cx), ty) { + scope_cx.need_new_lpad = true; + } } // Note that this only works for temporaries. We should, at some point, move @@ -320,7 +321,7 @@ fn revoke_clean(cx: @block_ctxt, val: ValueRef, t: ty::t) -> @block_ctxt { std::vec::slice(sc_cx.cleanups, 0u, found as uint) + std::vec::slice(sc_cx.cleanups, (found as uint) + 1u, std::vec::len(sc_cx.cleanups)); - sc_cx.cleanups_dirty = true; + sc_cx.need_new_lpad = true; ret cx; } @@ -393,7 +394,7 @@ type block_ctxt = parent: block_parent, kind: block_kind, mutable cleanups: [cleanup], - mutable cleanups_dirty: bool, + mutable need_new_lpad: bool, mutable lpad: option::t, sp: span, fcx: @fn_ctxt};