Skip to content

Commit 38fee95

Browse files
author
Elliott Slaughter
committed
rustc: When landing pads are off, avoid skipping cleanup code.
This forces various things to be created (e.g. drop glue), and also happens to be necessary for GC liveness to recognize cleanups as roots.
1 parent 5593add commit 38fee95

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/rustc/middle/trans/base.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,12 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint,
12331233
fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef,
12341234
field: uint, static_ti: Option<@tydesc_info>) {
12351235
let _icx = bcx.insn_ctxt("call_tydesc_glue_full");
1236-
if bcx.unreachable { return; }
12371236
let ccx = bcx.ccx();
1237+
// NB: Don't short-circuit even if this block is unreachable because
1238+
// GC-based cleanup needs to the see that the roots are live.
1239+
let no_lpads =
1240+
ccx.sess.opts.debugging_opts & session::no_landing_pads != 0;
1241+
if bcx.unreachable && !no_lpads { return; }
12381242

12391243
let static_glue_fn = match static_ti {
12401244
None => None,
@@ -4510,7 +4514,11 @@ fn trans_block_cleanups_(bcx: block,
45104514
/* cleanup_cx: block, */ is_lpad: bool) ->
45114515
block {
45124516
let _icx = bcx.insn_ctxt("trans_block_cleanups");
4513-
if bcx.unreachable { return bcx; }
4517+
// NB: Don't short-circuit even if this block is unreachable because
4518+
// GC-based cleanup needs to the see that the roots are live.
4519+
let no_lpads =
4520+
bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0;
4521+
if bcx.unreachable && !no_lpads { return bcx; }
45144522
let mut bcx = bcx;
45154523
do vec::riter(cleanups) |cu| {
45164524
match cu {

0 commit comments

Comments
 (0)