1+ use super :: query:: DepGraphQuery ;
2+ use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
3+ use super :: { DepContext , DepKind , DepNode , Deps , HasDepContext , WorkProductId } ;
4+ use crate :: dep_graph:: edges:: EdgesVec ;
5+ use crate :: ich:: StableHashingContext ;
6+ use crate :: query:: { QueryContext , QuerySideEffects } ;
17use rustc_data_structures:: fingerprint:: Fingerprint ;
28use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
39use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
410use rustc_data_structures:: sharded:: { self , Sharded } ;
511use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
612use rustc_data_structures:: steal:: Steal ;
7- use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
13+ use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , AtomicUsize , Lock , Lrc } ;
814use rustc_data_structures:: unord:: UnordMap ;
915use rustc_index:: IndexVec ;
1016use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
@@ -15,13 +21,6 @@ use std::hash::Hash;
1521use std:: marker:: PhantomData ;
1622use std:: sync:: atomic:: Ordering ;
1723
18- use super :: query:: DepGraphQuery ;
19- use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
20- use super :: { DepContext , DepKind , DepNode , Deps , HasDepContext , WorkProductId } ;
21- use crate :: dep_graph:: edges:: EdgesVec ;
22- use crate :: ich:: StableHashingContext ;
23- use crate :: query:: { QueryContext , QuerySideEffects } ;
24-
2524#[ cfg( debug_assertions) ]
2625use { super :: debug:: EdgeFilter , std:: env} ;
2726
@@ -218,6 +217,15 @@ impl<D: Deps> DepGraph<D> {
218217 D :: with_deps ( TaskDepsRef :: Ignore , op)
219218 }
220219
220+ pub ( crate ) fn with_replay < R > (
221+ & self ,
222+ prev_side_effects : & QuerySideEffects ,
223+ created_def_ids : & AtomicUsize ,
224+ op : impl FnOnce ( ) -> R ,
225+ ) -> R {
226+ D :: with_deps ( TaskDepsRef :: Replay { prev_side_effects, created_def_ids } , op)
227+ }
228+
221229 /// Used to wrap the deserialization of a query result from disk,
222230 /// This method enforces that no new `DepNodes` are created during
223231 /// query result deserialization.
@@ -272,6 +280,7 @@ impl<D: Deps> DepGraph<D> {
272280 }
273281
274282 #[ inline( always) ]
283+ /// A helper for `codegen_cranelift`.
275284 pub fn with_task < Ctxt : HasDepContext < Deps = D > , A : Debug , R > (
276285 & self ,
277286 key : DepNode ,
@@ -468,6 +477,12 @@ impl<D: Deps> DepGraph<D> {
468477 return ;
469478 }
470479 TaskDepsRef :: Ignore => return ,
480+ // We don't need to record dependencies when rerunning a query
481+ // because we have no disk cache entry to load. The dependencies
482+ // are preserved.
483+ // FIXME: assert that the dependencies don't change instead of
484+ // recording them.
485+ TaskDepsRef :: Replay { .. } => return ,
471486 TaskDepsRef :: Forbid => {
472487 panic ! ( "Illegal read of: {dep_node_index:?}" )
473488 }
@@ -573,6 +588,7 @@ impl<D: Deps> DepGraph<D> {
573588 edges. push ( DepNodeIndex :: FOREVER_RED_NODE ) ;
574589 }
575590 TaskDepsRef :: Ignore => { }
591+ TaskDepsRef :: Replay { .. } => { }
576592 TaskDepsRef :: Forbid => {
577593 panic ! ( "Cannot summarize when dependencies are not recorded." )
578594 }
@@ -1323,6 +1339,16 @@ pub enum TaskDepsRef<'a> {
13231339 /// to ensure that the decoding process doesn't itself
13241340 /// require the execution of any queries.
13251341 Forbid ,
1342+ /// Side effects from the previous run made available to
1343+ /// queries when they are reexecuted because their result was not
1344+ /// available in the cache. The query removes entries from the
1345+ /// side effect table. The table must be empty
1346+ Replay {
1347+ prev_side_effects : & ' a QuerySideEffects ,
1348+ /// Every new `DefId` is pushed here so we can check
1349+ /// that they match the cached ones.
1350+ created_def_ids : & ' a AtomicUsize ,
1351+ } ,
13261352}
13271353
13281354#[ derive( Debug ) ]
0 commit comments