mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Try a little harder to avoid creating new landing pads
It's only when we add or revoke cleanups involving immediates that we need a new landing pad for the scope. Trims 5K off the optimized rustc bin
This commit is contained in:
parent
74c39469be
commit
b8e31ac469
@ -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};
|
||||
|
@ -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<BasicBlockRef>,
|
||||
sp: span,
|
||||
fcx: @fn_ctxt};
|
||||
|
Loading…
Reference in New Issue
Block a user