Skip to content

Commit 7ec2710

Browse files
committed
---
yaml --- r: 39226 b: refs/heads/incoming c: 4fc03ba h: refs/heads/master v: v3
1 parent 81d79ab commit 7ec2710

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: aa3aa3b1b2b6d648af35122905d4958ad72377fb
9+
refs/heads/incoming: 4fc03bac654e6956024b52f2216c1803bb6ce7a6
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/librustc/driver/session.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const debug_llvm: uint = 1 << 13;
6565
const count_type_sizes: uint = 1 << 14;
6666
const meta_stats: uint = 1 << 15;
6767
const no_opt: uint = 1 << 16;
68+
const no_monomorphic_collapse: uint = 1 << 17;
6869

6970
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
7071
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
@@ -90,6 +91,8 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
9091
count_type_sizes),
9192
(~"meta-stats", ~"gather metadata statistics", meta_stats),
9293
(~"no-opt", ~"do not optimize, even if -O is passed", no_opt),
94+
(~"no-monomorphic-collapse", ~"do not collapse template instantiations",
95+
no_monomorphic_collapse),
9396
]
9497
}
9598

@@ -242,6 +245,9 @@ impl Session {
242245
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
243246
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
244247
fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) }
248+
fn no_monomorphic_collapse() -> bool {
249+
self.debugging_opt(no_monomorphic_collapse)
250+
}
245251

246252
fn str_of(id: ast::ident) -> ~str {
247253
*self.parse_sess.interner.get(id)

branches/incoming/src/librustc/middle/trans/monomorphize.rs

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -320,37 +320,43 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
320320
let param_ids = match param_uses {
321321
Some(uses) => {
322322
vec::map2(precise_param_ids, uses, |id, uses| {
323-
match *id {
324-
(a, b@Some(_)) => mono_precise(a, b),
325-
(subst, None) => {
326-
if *uses == 0u {
327-
mono_any
328-
} else if *uses == type_use::use_repr &&
329-
!ty::type_needs_drop(ccx.tcx, subst)
330-
{
331-
let llty = type_of::type_of(ccx, subst);
332-
let size = machine::llbitsize_of_real(ccx, llty);
333-
let align = shape::llalign_of_pref(ccx, llty);
334-
let mode = datum::appropriate_mode(subst);
323+
if ccx.sess.no_monomorphic_collapse() {
324+
match *id {
325+
(a, b) => mono_precise(a, b)
326+
}
327+
} else {
328+
match *id {
329+
(a, b@Some(_)) => mono_precise(a, b),
330+
(subst, None) => {
331+
if *uses == 0u {
332+
mono_any
333+
} else if *uses == type_use::use_repr &&
334+
!ty::type_needs_drop(ccx.tcx, subst)
335+
{
336+
let llty = type_of::type_of(ccx, subst);
337+
let size = machine::llbitsize_of_real(ccx, llty);
338+
let align = shape::llalign_of_pref(ccx, llty);
339+
let mode = datum::appropriate_mode(subst);
335340

336-
// FIXME(#3547)---scalars and floats are
337-
// treated differently in most ABIs. But we
338-
// should be doing something more detailed
339-
// here.
340-
let is_float = match ty::get(subst).sty {
341-
ty::ty_float(_) => true,
342-
_ => false
343-
};
341+
// FIXME(#3547)---scalars and floats are
342+
// treated differently in most ABIs. But we
343+
// should be doing something more detailed
344+
// here.
345+
let is_float = match ty::get(subst).sty {
346+
ty::ty_float(_) => true,
347+
_ => false
348+
};
344349

345-
// Special value for nil to prevent problems
346-
// with undef return pointers.
347-
if size <= 8u && ty::type_is_nil(subst) {
348-
mono_repr(0u, 0u, is_float, mode)
350+
// Special value for nil to prevent problems
351+
// with undef return pointers.
352+
if size <= 8u && ty::type_is_nil(subst) {
353+
mono_repr(0u, 0u, is_float, mode)
354+
} else {
355+
mono_repr(size, align, is_float, mode)
356+
}
349357
} else {
350-
mono_repr(size, align, is_float, mode)
358+
mono_precise(subst, None)
351359
}
352-
} else {
353-
mono_precise(subst, None)
354360
}
355361
}
356362
}

0 commit comments

Comments
 (0)