From 38fee9526a313104e3f869bf07c24b0c1d203d11 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Mon, 27 Aug 2012 12:31:32 -0700 Subject: [PATCH] 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. --- src/rustc/middle/trans/base.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 405a52cf7c8..ecfde4d01c7 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -1233,8 +1233,12 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef, field: uint, static_ti: Option<@tydesc_info>) { let _icx = bcx.insn_ctxt("call_tydesc_glue_full"); - if bcx.unreachable { return; } let ccx = bcx.ccx(); + // NB: Don't short-circuit even if this block is unreachable because + // GC-based cleanup needs to the see that the roots are live. + let no_lpads = + ccx.sess.opts.debugging_opts & session::no_landing_pads != 0; + if bcx.unreachable && !no_lpads { return; } let static_glue_fn = match static_ti { None => None, @@ -4510,7 +4514,11 @@ fn trans_block_cleanups_(bcx: block, /* cleanup_cx: block, */ is_lpad: bool) -> block { let _icx = bcx.insn_ctxt("trans_block_cleanups"); - if bcx.unreachable { return bcx; } + // NB: Don't short-circuit even if this block is unreachable because + // GC-based cleanup needs to the see that the roots are live. + let no_lpads = + bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0; + if bcx.unreachable && !no_lpads { return bcx; } let mut bcx = bcx; do vec::riter(cleanups) |cu| { match cu {