Skip to content

Commit e62ddf4

Browse files
committed
More rigorous reuse of cleanup sequences
In both landing pads and break/cont/ret unwinding. Closes #300
1 parent ea6bb5a commit e62ddf4

File tree

4 files changed

+171
-154
lines changed

4 files changed

+171
-154
lines changed

src/comp/middle/trans/alt.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,16 @@ fn trans_alt(cx: @block_ctxt, expr: @ast::expr, arms_: [ast::arm],
691691
a.pats[0])) {
692692
let arm_dest = base::dup_for_join(dest);
693693
arm_dests += [arm_dest];
694-
arm_cxs += [base::trans_block_dps(body_cx, a.body, arm_dest)];
694+
let arm_cx = base::trans_block(body_cx, a.body, arm_dest);
695+
arm_cx = base::trans_block_cleanups(arm_cx, body_cx);
696+
arm_cxs += [arm_cx];
695697
}
696698
i += 1u;
697699
}
698-
let after_cx = base::join_returns(cx, arm_cxs, arm_dests, dest);
699-
after_cx = base::trans_block_cleanups(after_cx, alt_cx);
700-
let next_cx = new_sub_block_ctxt(after_cx, "next");
701-
Br(after_cx, next_cx.llbb);
700+
let after_cx = base::join_returns(alt_cx, arm_cxs, arm_dests, dest);
701+
let next_cx = new_sub_block_ctxt(cx, "next");
702+
if after_cx.unreachable { Unreachable(next_cx); }
703+
base::cleanup_and_Br(after_cx, alt_cx, next_cx.llbb);
702704
ret next_cx;
703705
}
704706

0 commit comments

Comments
 (0)