diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-08-08 18:42:06 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-08-08 18:44:24 -0400 |
| commit | 8fdc72f830642abcd8dfefe5437e7df34390ce19 (patch) | |
| tree | d86ef07043d672c744aad4bb1489939ee4dcfd1b /src/librustc_trans | |
| parent | 88b2e9a66d6e95dde14742c0d3b05cde3683a732 (diff) | |
| download | rust-8fdc72f830642abcd8dfefe5437e7df34390ce19.tar.gz rust-8fdc72f830642abcd8dfefe5437e7df34390ce19.zip | |
track MIR through the dep-graph
Per the discussion on #34765, we make one `DepNode::Mir` variant and use it to represent both the MIR tracking map as well as passes that operate on MIR. We also track loads of cached MIR (which naturally comes from metadata). Note that the "HAIR" pass adds a read of TypeckItemBody because it uses a myriad of tables that are not individually tracked.
Diffstat (limited to 'src/librustc_trans')
| -rw-r--r-- | src/librustc_trans/context.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 5a3c1c8512a..909b3d06507 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -81,7 +81,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> { check_overflow: bool, check_drop_flag_for_sanity: bool, mir_map: &'a MirMap<'tcx>, - mir_cache: RefCell<DefIdMap<Rc<mir::Mir<'tcx>>>>, + mir_cache: RefCell<DepTrackingMap<MirCache<'tcx>>>, use_dll_storage_attrs: bool, @@ -186,6 +186,19 @@ impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> { } } +// Cache for mir loaded from metadata +struct MirCache<'tcx> { + data: PhantomData<&'tcx ()> +} + +impl<'tcx> DepTrackingMapConfig for MirCache<'tcx> { + type Key = DefId; + type Value = Rc<mir::Mir<'tcx>>; + fn to_dep_node(key: &DefId) -> DepNode<DefId> { + DepNode::Mir(*key) + } +} + /// This list owns a number of LocalCrateContexts and binds them to their common /// SharedCrateContext. This type just exists as a convenience, something to /// pass around all LocalCrateContexts with and get an iterator over them. @@ -474,7 +487,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { symbol_hasher: RefCell::new(symbol_hasher), tcx: tcx, mir_map: mir_map, - mir_cache: RefCell::new(DefIdMap()), + mir_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())), stats: Stats { n_glues_created: Cell::new(0), n_null_glues: Cell::new(0), @@ -538,8 +551,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { pub fn get_mir(&self, def_id: DefId) -> Option<CachedMir<'b, 'tcx>> { if def_id.is_local() { - let node_id = self.tcx.map.as_local_node_id(def_id).unwrap(); - self.mir_map.map.get(&node_id).map(CachedMir::Ref) + self.mir_map.map.get(&def_id).map(CachedMir::Ref) } else { if let Some(mir) = self.mir_cache.borrow().get(&def_id).cloned() { return Some(CachedMir::Owned(mir)); |
