librustc: Implement "-Z no-monomorphic-collapse" as a debugging tool to diagnose mysterious crashes we're seeing. rs=debug-tool
This commit is contained in:
parent
aa3aa3b1b2
commit
4fc03bac65
|
@ -65,6 +65,7 @@ const debug_llvm: uint = 1 << 13;
|
||||||
const count_type_sizes: uint = 1 << 14;
|
const count_type_sizes: uint = 1 << 14;
|
||||||
const meta_stats: uint = 1 << 15;
|
const meta_stats: uint = 1 << 15;
|
||||||
const no_opt: uint = 1 << 16;
|
const no_opt: uint = 1 << 16;
|
||||||
|
const no_monomorphic_collapse: uint = 1 << 17;
|
||||||
|
|
||||||
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
|
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
|
||||||
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
|
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
|
||||||
|
@ -90,6 +91,8 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
|
||||||
count_type_sizes),
|
count_type_sizes),
|
||||||
(~"meta-stats", ~"gather metadata statistics", meta_stats),
|
(~"meta-stats", ~"gather metadata statistics", meta_stats),
|
||||||
(~"no-opt", ~"do not optimize, even if -O is passed", no_opt),
|
(~"no-opt", ~"do not optimize, even if -O is passed", no_opt),
|
||||||
|
(~"no-monomorphic-collapse", ~"do not collapse template instantiations",
|
||||||
|
no_monomorphic_collapse),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +245,9 @@ impl Session {
|
||||||
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
|
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
|
||||||
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
|
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
|
||||||
fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) }
|
fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) }
|
||||||
|
fn no_monomorphic_collapse() -> bool {
|
||||||
|
self.debugging_opt(no_monomorphic_collapse)
|
||||||
|
}
|
||||||
|
|
||||||
fn str_of(id: ast::ident) -> ~str {
|
fn str_of(id: ast::ident) -> ~str {
|
||||||
*self.parse_sess.interner.get(id)
|
*self.parse_sess.interner.get(id)
|
||||||
|
|
|
@ -320,37 +320,43 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||||
let param_ids = match param_uses {
|
let param_ids = match param_uses {
|
||||||
Some(uses) => {
|
Some(uses) => {
|
||||||
vec::map2(precise_param_ids, uses, |id, uses| {
|
vec::map2(precise_param_ids, uses, |id, uses| {
|
||||||
match *id {
|
if ccx.sess.no_monomorphic_collapse() {
|
||||||
(a, b@Some(_)) => mono_precise(a, b),
|
match *id {
|
||||||
(subst, None) => {
|
(a, b) => mono_precise(a, b)
|
||||||
if *uses == 0u {
|
}
|
||||||
mono_any
|
} else {
|
||||||
} else if *uses == type_use::use_repr &&
|
match *id {
|
||||||
!ty::type_needs_drop(ccx.tcx, subst)
|
(a, b@Some(_)) => mono_precise(a, b),
|
||||||
{
|
(subst, None) => {
|
||||||
let llty = type_of::type_of(ccx, subst);
|
if *uses == 0u {
|
||||||
let size = machine::llbitsize_of_real(ccx, llty);
|
mono_any
|
||||||
let align = shape::llalign_of_pref(ccx, llty);
|
} else if *uses == type_use::use_repr &&
|
||||||
let mode = datum::appropriate_mode(subst);
|
!ty::type_needs_drop(ccx.tcx, subst)
|
||||||
|
{
|
||||||
|
let llty = type_of::type_of(ccx, subst);
|
||||||
|
let size = machine::llbitsize_of_real(ccx, llty);
|
||||||
|
let align = shape::llalign_of_pref(ccx, llty);
|
||||||
|
let mode = datum::appropriate_mode(subst);
|
||||||
|
|
||||||
// FIXME(#3547)---scalars and floats are
|
// FIXME(#3547)---scalars and floats are
|
||||||
// treated differently in most ABIs. But we
|
// treated differently in most ABIs. But we
|
||||||
// should be doing something more detailed
|
// should be doing something more detailed
|
||||||
// here.
|
// here.
|
||||||
let is_float = match ty::get(subst).sty {
|
let is_float = match ty::get(subst).sty {
|
||||||
ty::ty_float(_) => true,
|
ty::ty_float(_) => true,
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Special value for nil to prevent problems
|
// Special value for nil to prevent problems
|
||||||
// with undef return pointers.
|
// with undef return pointers.
|
||||||
if size <= 8u && ty::type_is_nil(subst) {
|
if size <= 8u && ty::type_is_nil(subst) {
|
||||||
mono_repr(0u, 0u, is_float, mode)
|
mono_repr(0u, 0u, is_float, mode)
|
||||||
|
} else {
|
||||||
|
mono_repr(size, align, is_float, mode)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mono_repr(size, align, is_float, mode)
|
mono_precise(subst, None)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
mono_precise(subst, None)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue