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.
This commit is contained in:
parent
601eca3b53
commit
4053b00112
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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> {
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user