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.
This commit is contained in:
Niko Matsakis 2016-08-08 18:42:06 -04:00
parent 88b2e9a66d
commit 8fdc72f830
14 changed files with 127 additions and 56 deletions

View file

@ -82,9 +82,11 @@ pub enum DepNode<D: Clone + Debug> {
Privacy,
IntrinsicCheck(D),
MatchCheck(D),
MirMapConstruction(D),
MirPass(D),
MirTypeck(D),
// Represents the MIR for a fn; also used as the task node for
// things read/modify that MIR.
Mir(D),
BorrowCheck(D),
RvalueCheck(D),
Reachability,
@ -214,9 +216,7 @@ impl<D: Clone + Debug> DepNode<D> {
CheckConst(ref d) => op(d).map(CheckConst),
IntrinsicCheck(ref d) => op(d).map(IntrinsicCheck),
MatchCheck(ref d) => op(d).map(MatchCheck),
MirMapConstruction(ref d) => op(d).map(MirMapConstruction),
MirPass(ref d) => op(d).map(MirPass),
MirTypeck(ref d) => op(d).map(MirTypeck),
Mir(ref d) => op(d).map(Mir),
BorrowCheck(ref d) => op(d).map(BorrowCheck),
RvalueCheck(ref d) => op(d).map(RvalueCheck),
TransCrateItem(ref d) => op(d).map(TransCrateItem),

View file

@ -61,6 +61,12 @@ impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
self.map.get(k)
}
pub fn get_mut(&mut self, k: &M::Key) -> Option<&mut M::Value> {
self.read(k);
self.write(k);
self.map.get_mut(k)
}
pub fn insert(&mut self, k: M::Key, v: M::Value) -> Option<M::Value> {
self.write(&k);
self.map.insert(k, v)
@ -70,6 +76,10 @@ impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
self.read(k);
self.map.contains_key(k)
}
pub fn keys(&self) -> Vec<M::Key> {
self.map.keys().cloned().collect()
}
}
impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {