Skip to content

Commit 13877ac

Browse files
committed
make available monomorphizations shared by CGU
The current setup means that all generics are local to a codegen-unit, which means massive duplication.
1 parent 43843d0 commit 13877ac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustc_trans/trans/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
7979
mir_map: &'a MirMap<'tcx>,
8080
mir_cache: RefCell<DefIdMap<Rc<mir::Mir<'tcx>>>>,
8181

82+
available_monomorphizations: RefCell<FnvHashSet<String>>,
8283
available_drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, String>>,
8384
use_dll_storage_attrs: bool,
8485

@@ -104,7 +105,6 @@ pub struct LocalCrateContext<'tcx> {
104105
/// Cache instances of monomorphic and polymorphic items
105106
instances: RefCell<FnvHashMap<Instance<'tcx>, ValueRef>>,
106107
monomorphizing: RefCell<DefIdMap<usize>>,
107-
available_monomorphizations: RefCell<FnvHashSet<String>>,
108108
/// Cache generated vtables
109109
vtables: RefCell<FnvHashMap<ty::PolyTraitRef<'tcx>, ValueRef>>,
110110
/// Cache of constant strings,
@@ -356,6 +356,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
356356
},
357357
check_overflow: check_overflow,
358358
check_drop_flag_for_sanity: check_drop_flag_for_sanity,
359+
available_monomorphizations: RefCell::new(FnvHashSet()),
359360
available_drop_glues: RefCell::new(FnvHashMap()),
360361
use_dll_storage_attrs: use_dll_storage_attrs,
361362
translation_items: RefCell::new(FnvHashMap()),
@@ -473,7 +474,6 @@ impl<'tcx> LocalCrateContext<'tcx> {
473474
external_srcs: RefCell::new(NodeMap()),
474475
instances: RefCell::new(FnvHashMap()),
475476
monomorphizing: RefCell::new(DefIdMap()),
476-
available_monomorphizations: RefCell::new(FnvHashSet()),
477477
vtables: RefCell::new(FnvHashMap()),
478478
const_cstr_cache: RefCell::new(FnvHashMap()),
479479
const_unsized: RefCell::new(FnvHashMap()),
@@ -723,7 +723,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
723723
}
724724

725725
pub fn available_monomorphizations<'a>(&'a self) -> &'a RefCell<FnvHashSet<String>> {
726-
&self.local.available_monomorphizations
726+
&self.shared.available_monomorphizations
727727
}
728728

729729
pub fn available_drop_glues(&self) -> &RefCell<FnvHashMap<DropGlueKind<'tcx>, String>> {

0 commit comments

Comments
 (0)