diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-03-25 11:57:55 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-03-26 14:08:55 +0100 |
| commit | 4053b00112f8c3d2c797adbb360a1961a82b6644 (patch) | |
| tree | 05aed5fc464ec0d956771a69b335cea964ceb1a2 | |
| parent | 601eca3b53a1a66a53a296f78428c1342b5f7758 (diff) | |
| download | rust-4053b00112f8c3d2c797adbb360a1961a82b6644.tar.gz rust-4053b00112f8c3d2c797adbb360a1961a82b6644.zip | |
Use `-Z force-dropflag-checks=on/off` for emitting sanity-check.
(That is, added config and debugflag a la check-overflow but for drop flag sanity-check.) Remove now-unused import of NoDebugInfo from trans::glue.
| -rw-r--r-- | src/librustc/session/config.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/trans/base.rs | 9 | ||||
| -rw-r--r-- | src/librustc_trans/trans/context.rs | 12 | ||||
| -rw-r--r-- | src/librustc_trans/trans/glue.rs | 3 |
4 files changed, 22 insertions, 4 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index a7c67a08631..c5498f5075e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -605,6 +605,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "Print the size of enums and their variants"), force_overflow_checks: Option<bool> = (None, parse_opt_bool, "Force overflow checks on or off"), + force_dropflag_checks: Option<bool> = (None, parse_opt_bool, + "Force drop flag checks on or off"), } pub fn default_lib_output() -> CrateType { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index aee163973fd..f482e4fa72b 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -3029,6 +3029,12 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>) tcx.sess.opts.debug_assertions }; + let check_dropflag = if let Some(v) = tcx.sess.opts.debugging_opts.force_dropflag_checks { + v + } else { + tcx.sess.opts.debug_assertions + }; + // Before we touch LLVM, make sure that multithreading is enabled. unsafe { use std::sync::{Once, ONCE_INIT}; @@ -3057,7 +3063,8 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>) Sha256::new(), link_meta.clone(), reachable, - check_overflow); + check_overflow, + check_dropflag); { let ccx = shared_ccx.get_ccx(0); diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 6614d538971..b834050a6d9 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -69,6 +69,7 @@ pub struct SharedCrateContext<'tcx> { tcx: ty::ctxt<'tcx>, stats: Stats, check_overflow: bool, + check_drop_flag_for_sanity: bool, available_monomorphizations: RefCell<FnvHashSet<String>>, available_drop_glues: RefCell<FnvHashMap<Ty<'tcx>, String>>, @@ -242,7 +243,8 @@ impl<'tcx> SharedCrateContext<'tcx> { symbol_hasher: Sha256, link_meta: LinkMeta, reachable: NodeSet, - check_overflow: bool) + check_overflow: bool, + check_drop_flag_for_sanity: bool) -> SharedCrateContext<'tcx> { let (metadata_llcx, metadata_llmod) = unsafe { create_context_and_module(&tcx.sess, "metadata") @@ -271,6 +273,7 @@ impl<'tcx> SharedCrateContext<'tcx> { fn_stats: RefCell::new(Vec::new()), }, check_overflow: check_overflow, + check_drop_flag_for_sanity: check_drop_flag_for_sanity, available_monomorphizations: RefCell::new(FnvHashSet()), available_drop_glues: RefCell::new(FnvHashMap()), }; @@ -727,6 +730,13 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { pub fn check_overflow(&self) -> bool { self.shared.check_overflow } + + pub fn check_drop_flag_for_sanity(&self) -> bool { + // This controls whether we emit a conditional llvm.debugtrap + // guarded on whether the dropflag is one of its (two) valid + // values. + self.shared.check_drop_flag_for_sanity + } } fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef> { diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 7eb4c6f8ca5..32b4d14177c 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -40,7 +40,6 @@ use util::ppaux; use arena::TypedArena; use libc::c_uint; -use session::config::NoDebugInfo; use syntax::ast; pub fn trans_exchange_free_dyn<'blk, 'tcx>(cx: Block<'blk, 'tcx>, @@ -237,7 +236,7 @@ fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let drop_flag_llty = type_of(bcx.fcx.ccx, bcx.tcx().dtor_type()); let init_val = C_integral(drop_flag_llty, adt::DTOR_NEEDED as u64, false); - let bcx = if bcx.tcx().sess.opts.debuginfo == NoDebugInfo { + let bcx = if !bcx.ccx().check_drop_flag_for_sanity() { bcx } else { let drop_flag_llty = type_of(bcx.fcx.ccx, bcx.tcx().dtor_type()); |
