Skip to content

Commit

Permalink
Try harder still to generate fewer landing pads
Browse files Browse the repository at this point in the history
Scopes that don't have cleanups don't need their own landing pads

This takes the optimized rustc bin from 4.7MB to 4.4
  • Loading branch information
brson committed Sep 13, 2011
1 parent b8e31ac commit 6d3dd0e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3738,7 +3738,7 @@ fn invoke_(bcx: @block_ctxt, llfn: ValueRef,
}

fn get_landing_pad(bcx: @block_ctxt) -> BasicBlockRef {
let scope_bcx = find_scope_cx(bcx);
let scope_bcx = find_scope_for_lpad(bcx);
if scope_bcx.need_new_lpad {
let unwind_bcx = new_sub_block_ctxt(bcx, "unwind");
let lpadbb = trans_landing_pad(unwind_bcx);
Expand All @@ -3747,6 +3747,24 @@ fn get_landing_pad(bcx: @block_ctxt) -> BasicBlockRef {
}
assert option::is_some(scope_bcx.lpad);
ret option::get(scope_bcx.lpad);

fn find_scope_for_lpad(bcx: @block_ctxt) -> @block_ctxt {
let scope_bcx = bcx;
while true {
scope_bcx = find_scope_cx(scope_bcx);
if vec::is_not_empty(scope_bcx.cleanups) {
ret scope_bcx;
} else {
scope_bcx = alt scope_bcx.parent {
parent_some(b) { b }
parent_none. {
ret scope_bcx;
}
}
}
}
fail;
}
}

fn trans_landing_pad(bcx: @block_ctxt) -> BasicBlockRef {
Expand Down

0 comments on commit 6d3dd0e

Please sign in to comment.