1use std::assert_matches;
2use std::cell::Cell;
3use std::fmt::Debug;
4use std::hash::Hash;
5use std::sync::Arc;
6use std::sync::atomic::{AtomicU32, Ordering};
78use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
9use rustc_data_structures::fx::FxHashSet;
10use rustc_data_structures::profiling::QueryInvocationId;
11use rustc_data_structures::sharded::{self, ShardedHashMap};
12use rustc_data_structures::stable_hash::{StableHash, StableHasher};
13use rustc_data_structures::sync::{AtomicU64, Lock, WorkerLocal};
14use rustc_data_structures::unord::UnordMap;
15use rustc_errors::DiagInner;
16use rustc_index::IndexVec;
17use rustc_macros::{Decodable, Encodable};
18use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
19use rustc_session::Session;
20use rustc_span::Symbol;
21use tracing::instrument;
22#[cfg(debug_assertions)]
23use {super::debug::EdgeFilter, std::env};
2425use super::retained::RetainedDepGraph;
26use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
27use super::{DepKind, DepNode, WorkProductId, read_deps, with_deps};
28use crate::dep_graph::edges::EdgesVec;
29use crate::ich::StableHashState;
30use crate::ty::TyCtxt;
31use crate::verify_ich::incremental_verify_ich;
3233/// Tracks 'side effects' for a particular query.
34/// This struct is saved to disk along with the query result,
35/// and loaded from disk if we mark the query as green.
36/// This allows us to 'replay' changes to global state
37/// that would otherwise only occur if we actually
38/// executed the query method.
39///
40/// Each side effect gets an unique dep node index which is added
41/// as a dependency of the query which had the effect.
42#[derive(#[automatically_derived]
impl ::core::fmt::Debug for QuerySideEffect {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
QuerySideEffect::Diagnostic(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Diagnostic", &__self_0),
QuerySideEffect::CheckFeature { symbol: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"CheckFeature", "symbol", &__self_0),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for QuerySideEffect {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
QuerySideEffect::Diagnostic(ref __binding_0) => { 0usize }
QuerySideEffect::CheckFeature { symbol: ref __binding_0 } =>
{
1usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
QuerySideEffect::Diagnostic(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
QuerySideEffect::CheckFeature { symbol: ref __binding_0 } =>
{
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for QuerySideEffect {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
QuerySideEffect::Diagnostic(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
QuerySideEffect::CheckFeature {
symbol: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `QuerySideEffect`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
43pub enum QuerySideEffect {
44/// Stores a diagnostic emitted during query execution.
45 /// This diagnostic will be re-emitted if we mark
46 /// the query as green, as that query will have the side
47 /// effect dep node as a dependency.
48Diagnostic(DiagInner),
49/// Records the feature used during query execution.
50 /// This feature will be inserted into `sess.used_features`
51 /// if we mark the query as green, as that query will have
52 /// the side effect dep node as a dependency.
53CheckFeature { symbol: Symbol },
54}
5556#[derive(#[automatically_derived]
impl ::core::clone::Clone for DepGraph {
#[inline]
fn clone(&self) -> DepGraph {
DepGraph {
data: ::core::clone::Clone::clone(&self.data),
virtual_dep_node_index: ::core::clone::Clone::clone(&self.virtual_dep_node_index),
}
}
}Clone)]
57pub struct DepGraph {
58 data: Option<Arc<DepGraphData>>,
5960/// This field is used for assigning DepNodeIndices when running in
61 /// non-incremental mode. Even in non-incremental mode we make sure that
62 /// each task has a `DepNodeIndex` that uniquely identifies it. This unique
63 /// ID is used for self-profiling.
64virtual_dep_node_index: Arc<AtomicU32>,
65}
6667impl ::std::fmt::Debug for DepNodeIndex {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("{0}", self.as_u32()))
}
}rustc_index::newtype_index! {
68pub struct DepNodeIndex {}
69}7071// We store a large collection of these in `prev_index_to_index` during
72// non-full incremental builds, and want to ensure that the element size
73// doesn't inadvertently increase.
74const _: [(); 4] = [(); ::std::mem::size_of::<Option<DepNodeIndex>>()];rustc_data_structures::static_assert_size!(Option<DepNodeIndex>, 4);
7576impl DepNodeIndex {
77const SINGLETON_ZERO_DEPS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO;
78pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
79}
8081impl From<DepNodeIndex> for QueryInvocationId {
82#[inline(always)]
83fn from(dep_node_index: DepNodeIndex) -> Self {
84QueryInvocationId(dep_node_index.as_u32())
85 }
86}
8788pub(crate) struct MarkFrame<'a> {
89 index: SerializedDepNodeIndex,
90 parent: Option<&'a MarkFrame<'a>>,
91}
9293/// The edge list of one node being marked green: it occupies `buf[start..]` of the shared
94/// scratch buffer and is popped again on drop, restoring the buffer for the enclosing call.
95struct EdgeFrame<'a> {
96 buf: &'a mut Vec<DepNodeIndex>,
97 start: usize,
98}
99100impl<'a> EdgeFrame<'a> {
101#[inline]
102fn new(buf: &'a mut Vec<DepNodeIndex>) -> Self {
103EdgeFrame { start: buf.len(), buf }
104 }
105106#[inline]
107fn push(&mut self, edge: DepNodeIndex) {
108self.buf.push(edge);
109 }
110111/// The edges pushed onto this frame so far.
112#[inline]
113fn get(&self) -> &[DepNodeIndex] {
114&self.buf[self.start..]
115 }
116}
117118impl Dropfor EdgeFrame<'_> {
119#[inline]
120fn drop(&mut self) {
121self.buf.truncate(self.start);
122 }
123}
124125#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DepNodeColor {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
DepNodeColor::Green(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Green",
&__self_0),
DepNodeColor::Red => ::core::fmt::Formatter::write_str(f, "Red"),
DepNodeColor::Unknown =>
::core::fmt::Formatter::write_str(f, "Unknown"),
}
}
}Debug)]
126pub(super) enum DepNodeColor {
127 Green(DepNodeIndex),
128 Red,
129 Unknown,
130}
131132pub struct DepGraphData {
133/// The new encoding of the dependency graph, optimized for red/green
134 /// tracking. The `current` field is the dependency graph of only the
135 /// current compilation session: We don't merge the previous dep-graph into
136 /// current one anymore, but we do reference shared data to save space.
137current: CurrentDepGraph,
138139/// The dep-graph from the previous compilation session. It contains all
140 /// nodes and edges as well as all fingerprints of nodes that have them.
141previous: Arc<SerializedDepGraph>,
142143 colors: DepNodeColorMap,
144145/// When we load, there may be `.o` files, cached MIR, or other such
146 /// things available to us. If we find that they are not dirty, we
147 /// load the path to the file storing those work-products here into
148 /// this map. We can later look for and extract that data.
149previous_work_products: WorkProductMap,
150151/// Used by incremental compilation tests to assert that
152 /// a particular query result was decoded from disk
153 /// (not just marked green)
154debug_loaded_from_disk: Lock<FxHashSet<DepNode>>,
155156/// Per-worker edge buffer amortized across `try_mark_green` calls.
157green_edge_buf: WorkerLocal<Cell<Vec<DepNodeIndex>>>,
158}
159160pub fn hash_result<R>(hcx: &mut StableHashState<'_>, result: &R) -> Fingerprint161where
162R: StableHash,
163{
164let mut stable_hasher = StableHasher::new();
165result.stable_hash(hcx, &mut stable_hasher);
166stable_hasher.finish()
167}
168169impl DepGraph {
170pub fn new(
171 session: &Session,
172 prev_graph: Arc<SerializedDepGraph>,
173 prev_work_products: WorkProductMap,
174 encoder: FileEncoder<'static>,
175 ) -> DepGraph {
176let prev_graph_node_count = prev_graph.node_count();
177178let current =
179CurrentDepGraph::new(session, prev_graph_node_count, encoder, Arc::clone(&prev_graph));
180181let colors = DepNodeColorMap::new(prev_graph_node_count);
182183// Instantiate a node with zero dependencies only once for anonymous queries.
184let _green_node_index = current.alloc_new_node(
185DepNode { kind: DepKind::AnonZeroDeps, key_fingerprint: current.anon_id_seed.into() },
186EdgesVec::new(),
187Fingerprint::ZERO,
188 );
189match (&_green_node_index, &DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val, &*right_val,
::core::option::Option::None);
}
}
};assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE);
190191// Create a single always-red node, with no dependencies of its own.
192 // Other nodes can use the always-red node as a fake dependency, to
193 // ensure that their dependency list will never be all-green.
194let red_node_index = current.alloc_new_node(
195DepNode { kind: DepKind::Red, key_fingerprint: Fingerprint::ZERO.into() },
196EdgesVec::new(),
197Fingerprint::ZERO,
198 );
199match (&red_node_index, &DepNodeIndex::FOREVER_RED_NODE) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val, &*right_val,
::core::option::Option::None);
}
}
};assert_eq!(red_node_index, DepNodeIndex::FOREVER_RED_NODE);
200if prev_graph_node_count > 0 {
201let prev_index =
202const { SerializedDepNodeIndex::from_u32(DepNodeIndex::FOREVER_RED_NODE.as_u32()) };
203let result = colors.try_set_color(prev_index, DesiredColor::Red);
204{
match result {
TrySetColorResult::Success => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"TrySetColorResult::Success", ::core::option::Option::None);
}
}
};assert_matches!(result, TrySetColorResult::Success);
205 }
206207DepGraph {
208 data: Some(Arc::new(DepGraphData {
209 previous_work_products: prev_work_products,
210current,
211 previous: prev_graph,
212colors,
213 debug_loaded_from_disk: Default::default(),
214 green_edge_buf: WorkerLocal::default(),
215 })),
216 virtual_dep_node_index: Arc::new(AtomicU32::new(0)),
217 }
218 }
219220pub fn new_disabled() -> DepGraph {
221DepGraph { data: None, virtual_dep_node_index: Arc::new(AtomicU32::new(0)) }
222 }
223224#[inline]
225pub fn data(&self) -> Option<&DepGraphData> {
226self.data.as_deref()
227 }
228229/// Returns `true` if we are actually building the full dep-graph, and `false` otherwise.
230#[inline]
231pub fn is_fully_enabled(&self) -> bool {
232self.data.is_some()
233 }
234235/// Returns a clone of the in-memory retained dep graph, if it is being built
236 /// (i.e. `-Zquery-dep-graph` is set). Cloning rather than exposing the lock keeps
237 /// callers from holding it while forcing queries, which would deadlock against a
238 /// reentrant `record` under the parallel frontend.
239pub fn retained_dep_graph(&self) -> Option<RetainedDepGraph> {
240self.data.as_ref().and_then(|data| data.current.encoder.retained_dep_graph())
241 }
242243pub fn assert_ignored(&self) {
244if let Some(..) = self.data {
245read_deps(|task_deps| {
246{
match task_deps {
TaskDepsRef::Ignore => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"TaskDepsRef::Ignore",
::core::option::Option::Some(format_args!("expected no task dependency tracking")));
}
}
};assert_matches!(
247 task_deps,
248 TaskDepsRef::Ignore,
249"expected no task dependency tracking"
250);
251 })
252 }
253 }
254255pub fn assert_eval_always(&self) {
256if self.data.is_some() {
257read_deps(|deps| {
258{
match deps {
TaskDepsRef::EvalAlways => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"TaskDepsRef::EvalAlways",
::core::option::Option::Some(format_args!("expected eval always context")));
}
}
}assert_matches!(deps, TaskDepsRef::EvalAlways, "expected eval always context")259 });
260 }
261 }
262263pub fn with_ignore<OP, R>(&self, op: OP) -> R
264where
265OP: FnOnce() -> R,
266 {
267with_deps(TaskDepsRef::Ignore, op)
268 }
269270/// Used to wrap the deserialization of a query result from disk,
271 /// This method enforces that no new `DepNodes` are created during
272 /// query result deserialization.
273 ///
274 /// Enforcing this makes the query dep graph simpler - all nodes
275 /// must be created during the query execution, and should be
276 /// created from inside the 'body' of a query (the implementation
277 /// provided by a particular compiler crate).
278 ///
279 /// Consider the case of three queries `A`, `B`, and `C`, where
280 /// `A` invokes `B` and `B` invokes `C`:
281 ///
282 /// `A -> B -> C`
283 ///
284 /// Suppose that decoding the result of query `B` required re-computing
285 /// the query `C`. If we did not create a fresh `TaskDeps` when
286 /// decoding `B`, we would still be using the `TaskDeps` for query `A`
287 /// (if we needed to re-execute `A`). This would cause us to create
288 /// a new edge `A -> C`. If this edge did not previously
289 /// exist in the `DepGraph`, then we could end up with a different
290 /// `DepGraph` at the end of compilation, even if there were no
291 /// meaningful changes to the overall program (e.g. a newline was added).
292 /// In addition, this edge might cause a subsequent compilation run
293 /// to try to force `C` before marking other necessary nodes green. If
294 /// `C` did not exist in the new compilation session, then we could
295 /// get an ICE. Normally, we would have tried (and failed) to mark
296 /// some other query green (e.g. `item_children`) which was used
297 /// to obtain `C`, which would prevent us from ever trying to force
298 /// a nonexistent `D`.
299 ///
300 /// It might be possible to enforce that all `DepNode`s read during
301 /// deserialization already exist in the previous `DepGraph`. In
302 /// the above example, we would invoke `D` during the deserialization
303 /// of `B`. Since we correctly create a new `TaskDeps` from the decoding
304 /// of `B`, this would result in an edge `B -> D`. If that edge already
305 /// existed (with the same `DepPathHash`es), then it should be correct
306 /// to allow the invocation of the query to proceed during deserialization
307 /// of a query result. We would merely assert that the dep-graph fragment
308 /// that would have been added by invoking `C` while decoding `B`
309 /// is equivalent to the dep-graph fragment that we already instantiated for B
310 /// (at the point where we successfully marked B as green).
311 ///
312 /// However, this would require additional complexity
313 /// in the query infrastructure, and is not currently needed by the
314 /// decoding of any query results. Should the need arise in the future,
315 /// we should consider extending the query system with this functionality.
316pub fn with_query_deserialization<OP, R>(&self, op: OP) -> R
317where
318OP: FnOnce() -> R,
319 {
320with_deps(TaskDepsRef::Forbid, op)
321 }
322323#[inline(always)]
324pub fn with_task<'tcx, OP, R>(
325&self,
326 dep_node: DepNode,
327 tcx: TyCtxt<'tcx>,
328 op: OP,
329 hash_result: Option<fn(&mut StableHashState<'_>, &R) -> Fingerprint>,
330 ) -> (R, DepNodeIndex)
331where
332OP: FnOnce() -> R,
333 {
334match self.data() {
335Some(data) => data.with_task(dep_node, tcx, op, hash_result),
336None => (op(), self.next_virtual_depnode_index()),
337 }
338 }
339340pub fn with_anon_task<'tcx, OP, R>(
341&self,
342 tcx: TyCtxt<'tcx>,
343 dep_kind: DepKind,
344 op: OP,
345 ) -> (R, DepNodeIndex)
346where
347OP: FnOnce() -> R,
348 {
349match self.data() {
350Some(data) => {
351let (result, index) = data.with_anon_task_inner(tcx, dep_kind, op);
352self.read_index(index);
353 (result, index)
354 }
355None => (op(), self.next_virtual_depnode_index()),
356 }
357 }
358}
359360impl DepGraphData {
361#[inline(always)]
362pub fn with_task<'tcx, OP, R>(
363&self,
364 dep_node: DepNode,
365 tcx: TyCtxt<'tcx>,
366 op: OP,
367 hash_result: Option<fn(&mut StableHashState<'_>, &R) -> Fingerprint>,
368 ) -> (R, DepNodeIndex)
369where
370OP: FnOnce() -> R,
371 {
372// If the following assertion triggers, it can have two reasons:
373 // 1. Something is wrong with DepNode creation, either here or
374 // in `DepGraph::try_mark_green()`.
375 // 2. Two distinct query keys get mapped to the same `DepNode`
376 // (see for example #48923).
377self.assert_dep_node_not_yet_allocated_in_current_session(tcx.sess, &dep_node, || {
378::alloc::__export::must_use({
::alloc::fmt::format(format_args!("forcing query with already existing `DepNode`: {0:?}",
dep_node))
})format!("forcing query with already existing `DepNode`: {dep_node:?}")379 });
380381let (result, edges) = if tcx.is_eval_always(dep_node.kind) {
382 (with_deps(TaskDepsRef::EvalAlways, op), EdgesVec::new())
383 } else {
384let task_deps = Lock::new(TaskDeps::new(
385#[cfg(debug_assertions)]
386Some(dep_node),
3870,
388 ));
389 (with_deps(TaskDepsRef::Allow(&task_deps), op), task_deps.into_inner().reads)
390 };
391392let dep_node_index =
393self.hash_result_and_alloc_node(tcx, dep_node, edges, &result, hash_result);
394395 (result, dep_node_index)
396 }
397398/// Executes something within an "anonymous" task, that is, a task the
399 /// `DepNode` of which is determined by the list of inputs it read from.
400 ///
401 /// NOTE: this does not actually count as a read of the DepNode here.
402 /// Using the result of this task without reading the DepNode will result
403 /// in untracked dependencies which may lead to ICEs as nodes are
404 /// incorrectly marked green.
405 ///
406 /// FIXME: This could perhaps return a `WithDepNode` to ensure that the
407 /// user of this function actually performs the read.
408fn with_anon_task_inner<'tcx, OP, R>(
409&self,
410 tcx: TyCtxt<'tcx>,
411 dep_kind: DepKind,
412 op: OP,
413 ) -> (R, DepNodeIndex)
414where
415OP: FnOnce() -> R,
416 {
417if true {
if !!tcx.is_eval_always(dep_kind) {
::core::panicking::panic("assertion failed: !tcx.is_eval_always(dep_kind)")
};
};debug_assert!(!tcx.is_eval_always(dep_kind));
418419// Large numbers of reads are common enough here that pre-sizing `read_set`
420 // to 128 actually helps perf on some benchmarks.
421let task_deps = Lock::new(TaskDeps::new(
422#[cfg(debug_assertions)]
423None,
424128,
425 ));
426let result = with_deps(TaskDepsRef::Allow(&task_deps), op);
427let task_deps = task_deps.into_inner();
428let reads = task_deps.reads;
429430let dep_node_index = match reads.len() {
4310 => {
432// Because the dep-node id of anon nodes is computed from the sets of its
433 // dependencies we already know what the ID of this dependency-less node is
434 // going to be (i.e. equal to the precomputed
435 // `SINGLETON_DEPENDENCYLESS_ANON_NODE`). As a consequence we can skip creating
436 // a `StableHasher` and sending the node through interning.
437DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE438 }
4391 => {
440// When there is only one dependency, don't bother creating a node.
441reads[0]
442 }
443_ => {
444// The dep node indices are hashed here instead of hashing the dep nodes of the
445 // dependencies. These indices may refer to different nodes per session, but this
446 // isn't a problem here because we that ensure the final dep node hash is per
447 // session only by combining it with the per session `anon_id_seed`. This hash only
448 // need to map the dependencies to a single value on a per session basis.
449let mut hasher = StableHasher::new();
450reads.hash(&mut hasher);
451452let target_dep_node = DepNode {
453 kind: dep_kind,
454// Fingerprint::combine() is faster than sending Fingerprint
455 // through the StableHasher (at least as long as StableHasher
456 // is so slow).
457key_fingerprint: self.current.anon_id_seed.combine(hasher.finish()).into(),
458 };
459460// The DepNodes generated by the process above are not unique. 2 queries could
461 // have exactly the same dependencies. However, deserialization does not handle
462 // duplicated nodes, so we do the deduplication here directly.
463 //
464 // As anonymous nodes are a small quantity compared to the full dep-graph, the
465 // memory impact of this `anon_node_to_index` map remains tolerable, and helps
466 // us avoid useless growth of the graph with almost-equivalent nodes.
467self.current.anon_node_to_index.get_or_insert_with(target_dep_node, || {
468self.current.alloc_new_node(target_dep_node, reads, Fingerprint::ZERO)
469 })
470 }
471 };
472473 (result, dep_node_index)
474 }
475476/// Intern the new `DepNode` with the dependencies up-to-now.
477fn hash_result_and_alloc_node<'tcx, R>(
478&self,
479 tcx: TyCtxt<'tcx>,
480 node: DepNode,
481 edges: EdgesVec,
482 result: &R,
483 hash_result: Option<fn(&mut StableHashState<'_>, &R) -> Fingerprint>,
484 ) -> DepNodeIndex {
485let hashing_timer = tcx.prof.incr_result_hashing();
486let current_fingerprint = hash_result.map(|hash_result| {
487tcx.with_stable_hashing_context(|mut hcx| hash_result(&mut hcx, result))
488 });
489let dep_node_index = self.alloc_and_color_node(node, edges, current_fingerprint);
490hashing_timer.finish_with_query_invocation_id(dep_node_index.into());
491dep_node_index492 }
493}
494495impl DepGraph {
496#[inline]
497pub fn read_index(&self, dep_node_index: DepNodeIndex) {
498if let Some(ref data) = self.data {
499read_deps(|task_deps| {
500let mut task_deps = match task_deps {
501 TaskDepsRef::Allow(deps) => deps.lock(),
502 TaskDepsRef::EvalAlways => {
503// We don't need to record dependencies of eval_always
504 // queries. They are re-evaluated unconditionally anyway.
505return;
506 }
507 TaskDepsRef::Ignore => return,
508 TaskDepsRef::Forbid => {
509// Reading is forbidden in this context. ICE with a useful error message.
510panic_on_forbidden_read(data, dep_node_index)
511 }
512 };
513let task_deps = &mut *task_deps;
514515if truecfg!(debug_assertions) {
516data.current.total_read_count.fetch_add(1, Ordering::Relaxed);
517 }
518519// Has `dep_node_index` been seen before? Use either a linear scan or a hashset
520 // lookup to determine this. See `TaskDeps::read_set` for details.
521let new_read = if task_deps.reads.len() <= TaskDeps::LINEAR_SCAN_MAX {
522 !task_deps.reads.contains(&dep_node_index)
523 } else {
524task_deps.read_set.insert(dep_node_index)
525 };
526if new_read {
527task_deps.reads.push(dep_node_index);
528if task_deps.reads.len() == TaskDeps::LINEAR_SCAN_MAX + 1 {
529// Fill `read_set` with what we have so far. Future lookups will use it.
530task_deps.read_set.extend(task_deps.reads.iter().copied());
531 }
532533#[cfg(debug_assertions)]
534{
535if let Some(target) = task_deps.node
536 && let Some(ref forbidden_edge) = data.current.forbidden_edge
537 {
538let src = forbidden_edge.index_to_node.lock()[&dep_node_index];
539if forbidden_edge.test(&src, &target) {
540{
::core::panicking::panic_fmt(format_args!("forbidden edge {0:?} -> {1:?} created",
src, target));
}panic!("forbidden edge {:?} -> {:?} created", src, target)541 }
542 }
543 }
544 } else if truecfg!(debug_assertions) {
545data.current.total_duplicate_read_count.fetch_add(1, Ordering::Relaxed);
546 }
547 })
548 }
549 }
550551/// This encodes a side effect by creating a node with an unique index and associating
552 /// it with the node, for use in the next session.
553#[inline]
554pub fn record_diagnostic<'tcx>(&self, tcx: TyCtxt<'tcx>, diagnostic: &DiagInner) {
555if let Some(ref data) = self.data {
556read_deps(|task_deps| match task_deps {
557 TaskDepsRef::EvalAlways | TaskDepsRef::Ignore => return,
558 TaskDepsRef::Forbid | TaskDepsRef::Allow(..) => {
559let dep_node_index = data560 .encode_side_effect(tcx, QuerySideEffect::Diagnostic(diagnostic.clone()));
561self.read_index(dep_node_index);
562 }
563 })
564 }
565 }
566/// This forces a side effect node green by running its side effect. `prev_index` would
567 /// refer to a node created used `encode_side_effect` in the previous session.
568#[inline]
569pub fn force_side_effect<'tcx>(&self, tcx: TyCtxt<'tcx>, prev_index: SerializedDepNodeIndex) {
570if let Some(ref data) = self.data {
571data.force_side_effect(tcx, prev_index);
572 }
573 }
574575#[inline]
576pub fn encode_side_effect<'tcx>(
577&self,
578 tcx: TyCtxt<'tcx>,
579 side_effect: QuerySideEffect,
580 ) -> DepNodeIndex {
581if let Some(ref data) = self.data {
582data.encode_side_effect(tcx, side_effect)
583 } else {
584self.next_virtual_depnode_index()
585 }
586 }
587588/// Create a node when we force-feed a value into the query cache.
589 /// This is used to remove cycles during type-checking const generic parameters.
590 ///
591 /// As usual in the query system, we consider the current state of the calling query
592 /// only depends on the list of dependencies up to now. As a consequence, the value
593 /// that this query gives us can only depend on those dependencies too. Therefore,
594 /// it is sound to use the current dependency set for the created node.
595 ///
596 /// During replay, the order of the nodes is relevant in the dependency graph.
597 /// So the unchanged replay will mark the caller query before trying to mark this one.
598 /// If there is a change to report, the caller query will be re-executed before this one.
599 ///
600 /// FIXME: If the code is changed enough for this node to be marked before requiring the
601 /// caller's node, we suppose that those changes will be enough to mark this node red and
602 /// force a recomputation using the "normal" way.
603pub fn with_feed_task<'tcx, R>(
604&self,
605 node: DepNode,
606 tcx: TyCtxt<'tcx>,
607 result: &R,
608 hash_result: Option<fn(&mut StableHashState<'_>, &R) -> Fingerprint>,
609 format_value_fn: fn(&R) -> String,
610 ) -> DepNodeIndex {
611if let Some(data) = self.data.as_ref() {
612// The caller query has more dependencies than the node we are creating. We may
613 // encounter a case where this created node is marked as green, but the caller query is
614 // subsequently marked as red or recomputed. In this case, we will end up feeding a
615 // value to an existing node.
616 //
617 // For sanity, we still check that the loaded stable hash and the new one match.
618if let Some(prev_index) = data.previous.node_to_index_opt(&node) {
619let dep_node_index = data.colors.current(prev_index);
620if let Some(dep_node_index) = dep_node_index {
621incremental_verify_ich(
622tcx,
623data,
624result,
625prev_index,
626hash_result,
627format_value_fn,
628 );
629630#[cfg(debug_assertions)]
631if hash_result.is_some() {
632data.current.record_edge(
633dep_node_index,
634node,
635data.prev_value_fingerprint_of(prev_index),
636 );
637 }
638639return dep_node_index;
640 }
641 }
642643let mut edges = EdgesVec::new();
644read_deps(|task_deps| match task_deps {
645 TaskDepsRef::Allow(deps) => edges.extend(deps.lock().reads.iter().copied()),
646 TaskDepsRef::EvalAlways => {
647edges.push(DepNodeIndex::FOREVER_RED_NODE);
648 }
649 TaskDepsRef::Ignore => {}
650 TaskDepsRef::Forbid => {
651{
::core::panicking::panic_fmt(format_args!("Cannot summarize when dependencies are not recorded."));
}panic!("Cannot summarize when dependencies are not recorded.")652 }
653 });
654655data.hash_result_and_alloc_node(tcx, node, edges, result, hash_result)
656 } else {
657// Incremental compilation is turned off. We just execute the task
658 // without tracking. We still provide a dep-node index that uniquely
659 // identifies the task so that we have a cheap way of referring to
660 // the query for self-profiling.
661self.next_virtual_depnode_index()
662 }
663 }
664}
665666impl DepGraphData {
667fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
668&self,
669 sess: &Session,
670 dep_node: &DepNode,
671 msg: impl FnOnce() -> S,
672 ) {
673if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) {
674let color = self.colors.get(prev_index);
675let ok = match color {
676 DepNodeColor::Unknown => true,
677 DepNodeColor::Red => false,
678 DepNodeColor::Green(..) => sess.threads().is_some(), // Other threads may mark this green
679};
680if !ok {
681{ ::core::panicking::panic_display(&msg()); }panic!("{}", msg())682 }
683 }
684 }
685686fn node_color(&self, dep_node: &DepNode) -> DepNodeColor {
687if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) {
688self.colors.get(prev_index)
689 } else {
690// This is a node that did not exist in the previous compilation session.
691DepNodeColor::Unknown692 }
693 }
694695/// Returns true if the given node has been marked as green during the
696 /// current compilation session. Used in various assertions
697#[inline]
698pub fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
699#[allow(non_exhaustive_omitted_patterns)] match self.colors.get(prev_index) {
DepNodeColor::Green(_) => true,
_ => false,
}matches!(self.colors.get(prev_index), DepNodeColor::Green(_))700 }
701702#[inline]
703pub fn prev_value_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint {
704self.previous.value_fingerprint_for_index(prev_index)
705 }
706707#[inline]
708pub(crate) fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> &DepNode {
709self.previous.index_to_node(prev_index)
710 }
711712pub fn mark_debug_loaded_from_disk(&self, dep_node: DepNode) {
713self.debug_loaded_from_disk.lock().insert(dep_node);
714 }
715716/// This encodes a side effect by creating a node with an unique index and associating
717 /// it with the node, for use in the next session.
718#[inline]
719fn encode_side_effect<'tcx>(
720&self,
721 tcx: TyCtxt<'tcx>,
722 side_effect: QuerySideEffect,
723 ) -> DepNodeIndex {
724// Use `send_new` so we get an unique index, even though the dep node is not.
725let dep_node_index = self.current.encoder.send_new(
726DepNode {
727 kind: DepKind::SideEffect,
728 key_fingerprint: PackedFingerprint::from(Fingerprint::ZERO),
729 },
730Fingerprint::ZERO,
731// We want the side effect node to always be red so it will be forced and run the
732 // side effect.
733std::iter::once(DepNodeIndex::FOREVER_RED_NODE).collect(),
734 );
735tcx.query_system.side_effects.borrow_mut().insert(dep_node_index, side_effect);
736dep_node_index737 }
738739/// This forces a side effect node green by running its side effect. `prev_index` would
740 /// refer to a node created used `encode_side_effect` in the previous session.
741#[inline]
742fn force_side_effect<'tcx>(&self, tcx: TyCtxt<'tcx>, prev_index: SerializedDepNodeIndex) {
743with_deps(TaskDepsRef::Ignore, || {
744let side_effect = tcx745 .query_system
746 .on_disk_cache
747 .as_ref()
748 .unwrap()
749 .load_side_effect(tcx, prev_index)
750 .unwrap();
751752// Use `send_and_color` as `promote_node_and_deps_to_current` expects all
753 // green dependencies. `send_and_color` will also prevent multiple nodes
754 // being encoded for concurrent calls.
755let dep_node_index = self.current.encoder.send_and_color(
756prev_index,
757&self.colors,
758DepNode {
759 kind: DepKind::SideEffect,
760 key_fingerprint: PackedFingerprint::from(Fingerprint::ZERO),
761 },
762Fingerprint::ZERO,
763 std::iter::once(DepNodeIndex::FOREVER_RED_NODE).collect(),
764true,
765 );
766767match &side_effect {
768 QuerySideEffect::Diagnostic(diagnostic) => {
769tcx.dcx().emit_diagnostic(diagnostic.clone());
770 }
771 QuerySideEffect::CheckFeature { symbol } => {
772tcx.sess.used_features.lock().insert(*symbol, dep_node_index.as_u32());
773 }
774 }
775776// This will just overwrite the same value for concurrent calls.
777tcx.query_system.side_effects.borrow_mut().insert(dep_node_index, side_effect);
778 })
779 }
780781fn alloc_and_color_node(
782&self,
783 key: DepNode,
784 edges: EdgesVec,
785 value_fingerprint: Option<Fingerprint>,
786 ) -> DepNodeIndex {
787if let Some(prev_index) = self.previous.node_to_index_opt(&key) {
788// Determine the color and index of the new `DepNode`.
789let is_green = if let Some(value_fingerprint) = value_fingerprint {
790if value_fingerprint == self.previous.value_fingerprint_for_index(prev_index) {
791// This is a green node: it existed in the previous compilation,
792 // its query was re-executed, and it has the same result as before.
793true
794} else {
795// This is a red node: it existed in the previous compilation, its query
796 // was re-executed, but it has a different result from before.
797false
798}
799 } else {
800// This is a red node, effectively: it existed in the previous compilation
801 // session, its query was re-executed, but it doesn't compute a result hash
802 // (i.e. it represents a `no_hash` query), so we have no way of determining
803 // whether or not the result was the same as before.
804false
805};
806807let value_fingerprint = value_fingerprint.unwrap_or(Fingerprint::ZERO);
808809let dep_node_index = self.current.encoder.send_and_color(
810prev_index,
811&self.colors,
812key,
813value_fingerprint,
814edges,
815is_green,
816 );
817818#[cfg(debug_assertions)]
819self.current.record_edge(dep_node_index, key, value_fingerprint);
820821dep_node_index822 } else {
823self.current.alloc_new_node(key, edges, value_fingerprint.unwrap_or(Fingerprint::ZERO))
824 }
825 }
826827fn promote_node_and_deps_to_current(
828&self,
829 prev_index: SerializedDepNodeIndex,
830 edges: &[DepNodeIndex],
831 ) -> Option<DepNodeIndex> {
832let dep_node_index = self.current.encoder.send_promoted(prev_index, &self.colors, edges);
833834#[cfg(debug_assertions)]
835if let Some(dep_node_index) = dep_node_index {
836self.current.record_edge(
837dep_node_index,
838*self.previous.index_to_node(prev_index),
839self.previous.value_fingerprint_for_index(prev_index),
840 );
841 }
842843dep_node_index844 }
845}
846847impl DepGraph {
848/// Checks whether a previous work product exists for `v` and, if
849 /// so, return the path that leads to it. Used to skip doing work.
850pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct> {
851self.data.as_ref().and_then(|data| data.previous_work_products.get(v).cloned())
852 }
853854/// Access the map of work-products created during the cached run. Only
855 /// used during saving of the dep-graph.
856pub fn previous_work_products(&self) -> &WorkProductMap {
857&self.data.as_ref().unwrap().previous_work_products
858 }
859860pub fn debug_was_loaded_from_disk(&self, dep_node: DepNode) -> bool {
861self.data.as_ref().unwrap().debug_loaded_from_disk.lock().contains(&dep_node)
862 }
863864pub fn debug_dep_kind_was_loaded_from_disk(&self, dep_kind: DepKind) -> bool {
865// We only check if we have a dep node corresponding to the given dep kind.
866#[allow(rustc::potential_query_instability)]
867self.data
868 .as_ref()
869 .unwrap()
870 .debug_loaded_from_disk
871 .lock()
872 .iter()
873 .any(|node| node.kind == dep_kind)
874 }
875876fn node_color(&self, dep_node: &DepNode) -> DepNodeColor {
877if let Some(ref data) = self.data {
878return data.node_color(dep_node);
879 }
880881 DepNodeColor::Unknown882 }
883884pub fn try_mark_green<'tcx>(
885&self,
886 tcx: TyCtxt<'tcx>,
887 dep_node: &DepNode,
888 ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
889self.data()?.try_mark_green(tcx, dep_node)
890 }
891}
892893impl DepGraphData {
894/// Try to mark a node index for the node dep_node.
895 ///
896 /// A node will have an index, when it's already been marked green, or when we can mark it
897 /// green. This function will mark the current task as a reader of the specified node, when
898 /// a node index can be found for that node.
899pub fn try_mark_green<'tcx>(
900&self,
901 tcx: TyCtxt<'tcx>,
902 dep_node: &DepNode,
903 ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
904if true {
if !!tcx.is_eval_always(dep_node.kind) {
::core::panicking::panic("assertion failed: !tcx.is_eval_always(dep_node.kind)")
};
};debug_assert!(!tcx.is_eval_always(dep_node.kind));
905906// Return None if the dep node didn't exist in the previous session
907let prev_index = self.previous.node_to_index_opt(dep_node)?;
908909if true {
match (&self.previous.index_to_node(prev_index), &dep_node) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
};
};debug_assert_eq!(self.previous.index_to_node(prev_index), dep_node);
910911match self.colors.get(prev_index) {
912 DepNodeColor::Green(dep_node_index) => Some((prev_index, dep_node_index)),
913 DepNodeColor::Red => None,
914 DepNodeColor::Unknown => {
915// This DepNode and the corresponding query invocation existed
916 // in the previous compilation session too, so we can try to
917 // mark it as green by recursively marking all of its
918 // dependencies green.
919920 // Reuse a per-worker buffer for the edges instead of allocating one per call.
921 // The recursion gives it back empty: each `EdgeFrame` pops its edges on drop.
922let mut edge_buf = self.green_edge_buf.take();
923let result = self.try_mark_previous_green(tcx, prev_index, None, &mut edge_buf);
924if true {
if !edge_buf.is_empty() {
::core::panicking::panic("assertion failed: edge_buf.is_empty()")
};
};debug_assert!(edge_buf.is_empty());
925self.green_edge_buf.set(edge_buf);
926result.map(|dep_node_index| (prev_index, dep_node_index))
927 }
928 }
929 }
930931/// Try to mark a dep-node which existed in the previous compilation session as green.
932#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("try_mark_previous_green",
"rustc_middle::dep_graph::graph", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/dep_graph/graph.rs"),
::tracing_core::__macro_support::Option::Some(932u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::dep_graph::graph"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set(&[]) })
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: Option<DepNodeIndex> = loop {};
return __tracing_attr_fake_return;
}
{
let mut edges = EdgeFrame::new(edge_buf);
let frame =
MarkFrame { index: prev_dep_node_index, parent: frame };
if true {
if !!tcx.is_eval_always(self.previous.index_to_node(prev_dep_node_index).kind)
{
::core::panicking::panic("assertion failed: !tcx.is_eval_always(self.previous.index_to_node(prev_dep_node_index).kind)")
};
};
for parent_dep_node_index in
self.previous.edge_targets_from(prev_dep_node_index) {
match self.colors.get(parent_dep_node_index) {
DepNodeColor::Green(parent_index) => {
edges.push(parent_index);
continue;
}
DepNodeColor::Red => return None,
DepNodeColor::Unknown => {}
}
let parent_dep_node =
self.previous.index_to_node(parent_dep_node_index);
if !tcx.is_eval_always(parent_dep_node.kind) &&
let Some(parent_index) =
self.try_mark_previous_green(tcx, parent_dep_node_index,
Some(&frame), edges.buf) {
edges.push(parent_index);
continue;
}
if !tcx.try_force_from_dep_node(*parent_dep_node,
parent_dep_node_index, &frame) {
return None;
}
match self.colors.get(parent_dep_node_index) {
DepNodeColor::Green(parent_index) => {
edges.push(parent_index);
continue;
}
DepNodeColor::Red => return None,
DepNodeColor::Unknown => {}
}
if tcx.dcx().has_errors_or_delayed_bugs().is_none() {
{
::core::panicking::panic_fmt(format_args!("try_mark_previous_green() - forcing failed to set a color"));
};
}
return None;
}
let dep_node_index =
self.promote_node_and_deps_to_current(prev_dep_node_index,
edges.get())?;
Some(dep_node_index)
}
}
}#[instrument(skip(self, tcx, prev_dep_node_index, frame, edge_buf), level = "debug")]933fn try_mark_previous_green<'tcx>(
934&self,
935 tcx: TyCtxt<'tcx>,
936 prev_dep_node_index: SerializedDepNodeIndex,
937 frame: Option<&MarkFrame<'_>>,
938// Amortized buffer to store edges in.
939edge_buf: &mut Vec<DepNodeIndex>,
940 ) -> Option<DepNodeIndex> {
941let mut edges = EdgeFrame::new(edge_buf);
942let frame = MarkFrame { index: prev_dep_node_index, parent: frame };
943944// We never try to mark eval_always nodes as green
945debug_assert!(!tcx.is_eval_always(self.previous.index_to_node(prev_dep_node_index).kind));
946947for parent_dep_node_index in self.previous.edge_targets_from(prev_dep_node_index) {
948match self.colors.get(parent_dep_node_index) {
949// This dependency has been marked as green before, we are still ok and can
950 // continue checking the remaining dependencies.
951DepNodeColor::Green(parent_index) => {
952 edges.push(parent_index);
953continue;
954 }
955956// This dependency's result is different to the previous compilation session. We
957 // cannot mark this dep_node as green, so stop checking.
958DepNodeColor::Red => return None,
959960// We still need to determine this dependency's colour.
961DepNodeColor::Unknown => {}
962 }
963964let parent_dep_node = self.previous.index_to_node(parent_dep_node_index);
965966// If this dependency isn't eval_always, try to mark it green recursively.
967if !tcx.is_eval_always(parent_dep_node.kind)
968 && let Some(parent_index) = self.try_mark_previous_green(
969 tcx,
970 parent_dep_node_index,
971Some(&frame),
972// Pass the edge buffer to the recursive call.
973 // It will use an `EdgeFrame` to give it back unchanged.
974edges.buf,
975 )
976 {
977 edges.push(parent_index);
978continue;
979 }
980981// We failed to mark it green, so we try to force the query.
982if !tcx.try_force_from_dep_node(*parent_dep_node, parent_dep_node_index, &frame) {
983return None;
984 }
985986match self.colors.get(parent_dep_node_index) {
987 DepNodeColor::Green(parent_index) => {
988 edges.push(parent_index);
989continue;
990 }
991 DepNodeColor::Red => return None,
992 DepNodeColor::Unknown => {}
993 }
994995if tcx.dcx().has_errors_or_delayed_bugs().is_none() {
996panic!("try_mark_previous_green() - forcing failed to set a color");
997 }
998999// If the query we just forced has resulted in some kind of compilation error, we
1000 // cannot rely on the dep-node color having been properly updated. This means that the
1001 // query system has reached an invalid state. We let the compiler continue (by
1002 // returning `None`) so it can emit error messages and wind down, but rely on the fact
1003 // that this invalid state will not be persisted to the incremental compilation cache
1004 // because of compilation errors being present.
1005return None;
1006 }
10071008// If we got here without hitting a `return` that means that all
1009 // dependencies of this DepNode could be marked as green. Therefore we
1010 // can also mark this DepNode as green.
10111012 // There may be multiple threads trying to mark the same dep node green concurrently.
10131014 // We allocating an entry for the node in the current dependency graph and
1015 // adding all the appropriate edges imported from the previous graph.
1016 //
1017 // `no_hash` nodes may fail this promotion due to already being conservatively colored red.
1018let dep_node_index =
1019self.promote_node_and_deps_to_current(prev_dep_node_index, edges.get())?;
10201021// ... and finally storing a "Green" entry in the color map.
1022 // Multiple threads can all write the same color here.
10231024Some(dep_node_index)
1025 }
1026}
10271028impl DepGraph {
1029/// Returns true if the given node has been marked as red during the
1030 /// current compilation session. Used in various assertions
1031pub fn is_red(&self, dep_node: &DepNode) -> bool {
1032#[allow(non_exhaustive_omitted_patterns)] match self.node_color(dep_node) {
DepNodeColor::Red => true,
_ => false,
}matches!(self.node_color(dep_node), DepNodeColor::Red)1033 }
10341035/// Returns true if the given node has been marked as green during the
1036 /// current compilation session. Used in various assertions
1037pub fn is_green(&self, dep_node: &DepNode) -> bool {
1038#[allow(non_exhaustive_omitted_patterns)] match self.node_color(dep_node) {
DepNodeColor::Green(_) => true,
_ => false,
}matches!(self.node_color(dep_node), DepNodeColor::Green(_))1039 }
10401041pub fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
1042&self,
1043 sess: &Session,
1044 dep_node: &DepNode,
1045 msg: impl FnOnce() -> S,
1046 ) {
1047if let Some(data) = &self.data {
1048data.assert_dep_node_not_yet_allocated_in_current_session(sess, dep_node, msg)
1049 }
1050 }
10511052/// This method loads all on-disk cacheable query results into memory, so
1053 /// they can be written out to the new cache file again. Most query results
1054 /// will already be in memory but in the case where we marked something as
1055 /// green but then did not need the value, that value will never have been
1056 /// loaded from disk.
1057 ///
1058 /// This method will only load queries that will end up in the disk cache.
1059 /// Other queries will not be executed.
1060pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx>) {
1061let _prof_timer = tcx.prof.generic_activity("incr_comp_query_cache_promotion");
10621063let data = self.data.as_ref().unwrap();
1064for prev_index in data.colors.values.indices() {
1065match data.colors.get(prev_index) {
1066 DepNodeColor::Green(_) => {
1067let dep_node = data.previous.index_to_node(prev_index);
1068if let Some(promote_fn) =
1069 tcx.dep_kind_vtable(dep_node.kind).promote_from_disk_fn
1070 {
1071 promote_fn(tcx, *dep_node)
1072 };
1073 }
1074 DepNodeColor::Unknown | DepNodeColor::Red => {
1075// We can skip red nodes because a node can only be marked
1076 // as red if the query result was recomputed and thus is
1077 // already in memory.
1078}
1079 }
1080 }
1081 }
10821083pub(crate) fn finish_encoding(&self) -> FileEncodeResult {
1084if let Some(data) = &self.data { data.current.encoder.finish(&data.current) } else { Ok(0) }
1085 }
10861087pub fn next_virtual_depnode_index(&self) -> DepNodeIndex {
1088if true {
if !self.data.is_none() {
::core::panicking::panic("assertion failed: self.data.is_none()")
};
};debug_assert!(self.data.is_none());
1089let index = self.virtual_dep_node_index.fetch_add(1, Ordering::Relaxed);
1090DepNodeIndex::from_u32(index)
1091 }
1092}
10931094/// A "work product" is an intermediate result that we save into the
1095/// incremental directory for later re-use. The primary example are
1096/// the object files that we save for each partition at code
1097/// generation time.
1098///
1099/// Each work product is associated with a dep-node, representing the
1100/// process that produced the work-product. If that dep-node is found
1101/// to be dirty when we load up, then we will delete the work-product
1102/// at load time. If the work-product is found to be clean, then we
1103/// will keep a record in the `previous_work_products` list.
1104///
1105/// In addition, work products have an associated hash. This hash is
1106/// an extra hash that can be used to decide if the work-product from
1107/// a previous compilation can be re-used (in addition to the dirty
1108/// edges check).
1109///
1110/// As the primary example, consider the object files we generate for
1111/// each partition. In the first run, we create partitions based on
1112/// the symbols that need to be compiled. For each partition P, we
1113/// hash the symbols in P and create a `WorkProduct` record associated
1114/// with `DepNode::CodegenUnit(P)`; the hash is the set of symbols
1115/// in P.
1116///
1117/// The next time we compile, if the `DepNode::CodegenUnit(P)` is
1118/// judged to be clean (which means none of the things we read to
1119/// generate the partition were found to be dirty), it will be loaded
1120/// into previous work products. We will then regenerate the set of
1121/// symbols in the partition P and hash them (note that new symbols
1122/// may be added -- for example, new monomorphizations -- even if
1123/// nothing in P changed!). We will compare that hash against the
1124/// previous hash. If it matches up, we can reuse the object file.
1125#[derive(#[automatically_derived]
impl ::core::clone::Clone for WorkProduct {
#[inline]
fn clone(&self) -> WorkProduct {
WorkProduct {
cgu_name: ::core::clone::Clone::clone(&self.cgu_name),
saved_files: ::core::clone::Clone::clone(&self.saved_files),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for WorkProduct {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "WorkProduct",
"cgu_name", &self.cgu_name, "saved_files", &&self.saved_files)
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for WorkProduct {
fn encode(&self, __encoder: &mut __E) {
match *self {
WorkProduct {
cgu_name: ref __binding_0, saved_files: ref __binding_1 } =>
{
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for WorkProduct {
fn decode(__decoder: &mut __D) -> Self {
WorkProduct {
cgu_name: ::rustc_serialize::Decodable::decode(__decoder),
saved_files: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1126pub struct WorkProduct {
1127pub cgu_name: String,
1128/// Saved files associated with this CGU. In each key/value pair, the value is the path to the
1129 /// saved file and the key is some identifier for the type of file being saved.
1130 ///
1131 /// By convention, file extensions are currently used as identifiers, i.e. the key "o" maps to
1132 /// the object file's path, and "dwo" to the dwarf object file's path.
1133pub saved_files: UnordMap<String, String>,
1134}
11351136pub type WorkProductMap = UnordMap<WorkProductId, WorkProduct>;
11371138// Index type for `DepNodeData`'s edges.
1139impl ::std::fmt::Debug for EdgeIndex {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("{0}", self.as_u32()))
}
}rustc_index::newtype_index! {
1140struct EdgeIndex {}
1141}11421143/// `CurrentDepGraph` stores the dependency graph for the current session. It
1144/// will be populated as we run queries or tasks. We never remove nodes from the
1145/// graph: they are only added.
1146///
1147/// The nodes in it are identified by a `DepNodeIndex`. We avoid keeping the nodes
1148/// in memory. This is important, because these graph structures are some of the
1149/// largest in the compiler.
1150///
1151/// For this reason, we avoid storing `DepNode`s more than once as map
1152/// keys. The `anon_node_to_index` map only contains nodes of anonymous queries not in the previous
1153/// graph, and we map nodes in the previous graph to indices via a two-step
1154/// mapping. `SerializedDepGraph` maps from `DepNode` to `SerializedDepNodeIndex`,
1155/// and the `prev_index_to_index` vector (which is more compact and faster than
1156/// using a map) maps from `SerializedDepNodeIndex` to `DepNodeIndex`.
1157///
1158/// This struct uses three locks internally. The `data`, `anon_node_to_index`,
1159/// and `prev_index_to_index` fields are locked separately. Operations that take
1160/// a `DepNodeIndex` typically just access the `data` field.
1161///
1162/// We only need to manipulate at most two locks simultaneously:
1163/// `anon_node_to_index` and `data`, or `prev_index_to_index` and `data`. When
1164/// manipulating both, we acquire `anon_node_to_index` or `prev_index_to_index`
1165/// first, and `data` second.
1166pub(super) struct CurrentDepGraph {
1167 encoder: GraphEncoder,
1168 anon_node_to_index: ShardedHashMap<DepNode, DepNodeIndex>,
11691170/// This is used to verify that value fingerprints do not change between the
1171 /// creation of a node and its recomputation.
1172#[cfg(debug_assertions)]
1173value_fingerprints: Lock<IndexVec<DepNodeIndex, Option<Fingerprint>>>,
11741175/// Used to trap when a specific edge is added to the graph.
1176 /// This is used for debug purposes and is only active with `debug_assertions`.
1177#[cfg(debug_assertions)]
1178forbidden_edge: Option<EdgeFilter>,
11791180/// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
1181 /// their edges. This has the beneficial side-effect that multiple anonymous
1182 /// nodes can be coalesced into one without changing the semantics of the
1183 /// dependency graph. However, the merging of nodes can lead to a subtle
1184 /// problem during red-green marking: The color of an anonymous node from
1185 /// the current session might "shadow" the color of the node with the same
1186 /// ID from the previous session. In order to side-step this problem, we make
1187 /// sure that anonymous `NodeId`s allocated in different sessions don't overlap.
1188 /// This is implemented by mixing a session-key into the ID fingerprint of
1189 /// each anon node. The session-key is a hash of the number of previous sessions.
1190anon_id_seed: Fingerprint,
11911192/// These are simple counters that are for profiling and
1193 /// debugging and only active with `debug_assertions`.
1194pub(super) total_read_count: AtomicU64,
1195pub(super) total_duplicate_read_count: AtomicU64,
1196}
11971198impl CurrentDepGraph {
1199fn new(
1200 session: &Session,
1201 prev_graph_node_count: usize,
1202 encoder: FileEncoder<'static>,
1203 previous: Arc<SerializedDepGraph>,
1204 ) -> Self {
1205let mut stable_hasher = StableHasher::new();
1206previous.session_count().hash(&mut stable_hasher);
1207let anon_id_seed = stable_hasher.finish();
12081209#[cfg(debug_assertions)]
1210let forbidden_edge = match env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
1211Ok(s) => match EdgeFilter::new(&s) {
1212Ok(f) => Some(f),
1213Err(err) => {
::core::panicking::panic_fmt(format_args!("RUST_FORBID_DEP_GRAPH_EDGE invalid: {0}",
err));
}panic!("RUST_FORBID_DEP_GRAPH_EDGE invalid: {}", err),
1214 },
1215Err(_) => None,
1216 };
12171218let new_node_count_estimate = 102 * prev_graph_node_count / 100 + 200;
12191220CurrentDepGraph {
1221 encoder: GraphEncoder::new(session, encoder, prev_graph_node_count, previous),
1222 anon_node_to_index: ShardedHashMap::with_capacity(
1223// FIXME: The count estimate is off as anon nodes are only a portion of the nodes.
1224new_node_count_estimate / sharded::shards(),
1225 ),
1226anon_id_seed,
1227#[cfg(debug_assertions)]
1228forbidden_edge,
1229#[cfg(debug_assertions)]
1230value_fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),
1231 total_read_count: AtomicU64::new(0),
1232 total_duplicate_read_count: AtomicU64::new(0),
1233 }
1234 }
12351236#[cfg(debug_assertions)]
1237fn record_edge(
1238&self,
1239 dep_node_index: DepNodeIndex,
1240 key: DepNode,
1241 value_fingerprint: Fingerprint,
1242 ) {
1243if let Some(forbidden_edge) = &self.forbidden_edge {
1244forbidden_edge.index_to_node.lock().insert(dep_node_index, key);
1245 }
1246let prior_value_fingerprint = *self1247 .value_fingerprints
1248 .lock()
1249 .get_or_insert_with(dep_node_index, || value_fingerprint);
1250match (&prior_value_fingerprint, &value_fingerprint) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val, &*right_val,
::core::option::Option::Some(format_args!("Unstable fingerprints for {0:?}",
key)));
}
}
};assert_eq!(prior_value_fingerprint, value_fingerprint, "Unstable fingerprints for {key:?}");
1251 }
12521253/// Writes the node to the current dep-graph and allocates a `DepNodeIndex` for it.
1254 /// Assumes that this is a node that has no equivalent in the previous dep-graph.
1255#[inline(always)]
1256fn alloc_new_node(
1257&self,
1258 key: DepNode,
1259 edges: EdgesVec,
1260 value_fingerprint: Fingerprint,
1261 ) -> DepNodeIndex {
1262let dep_node_index = self.encoder.send_new(key, value_fingerprint, edges);
12631264#[cfg(debug_assertions)]
1265self.record_edge(dep_node_index, key, value_fingerprint);
12661267dep_node_index1268 }
1269}
12701271#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for TaskDepsRef<'a> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TaskDepsRef::Allow(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Allow",
&__self_0),
TaskDepsRef::EvalAlways =>
::core::fmt::Formatter::write_str(f, "EvalAlways"),
TaskDepsRef::Ignore =>
::core::fmt::Formatter::write_str(f, "Ignore"),
TaskDepsRef::Forbid =>
::core::fmt::Formatter::write_str(f, "Forbid"),
}
}
}Debug, #[automatically_derived]
impl<'a> ::core::clone::Clone for TaskDepsRef<'a> {
#[inline]
fn clone(&self) -> TaskDepsRef<'a> {
let _: ::core::clone::AssertParamIsClone<&'a Lock<TaskDeps>>;
*self
}
}Clone, #[automatically_derived]
impl<'a> ::core::marker::Copy for TaskDepsRef<'a> { }Copy)]
1272pub enum TaskDepsRef<'a> {
1273/// New dependencies can be added to the
1274 /// `TaskDeps`. This is used when executing a 'normal' query
1275 /// (no `eval_always` modifier)
1276Allow(&'a Lock<TaskDeps>),
1277/// This is used when executing an `eval_always` query. We don't
1278 /// need to track dependencies for a query that's always
1279 /// re-executed -- but we need to know that this is an `eval_always`
1280 /// query in order to emit dependencies to `DepNodeIndex::FOREVER_RED_NODE`
1281 /// when directly feeding other queries.
1282EvalAlways,
1283/// New dependencies are ignored. This is also used for `dep_graph.with_ignore`.
1284Ignore,
1285/// Any attempt to add new dependencies will cause a panic.
1286 /// This is used when decoding a query result from disk,
1287 /// to ensure that the decoding process doesn't itself
1288 /// require the execution of any queries.
1289Forbid,
1290}
12911292#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TaskDeps {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "TaskDeps",
"node", &self.node, "reads", &self.reads, "read_set",
&&self.read_set)
}
}Debug)]
1293pub struct TaskDeps {
1294#[cfg(debug_assertions)]
1295node: Option<DepNode>,
12961297/// A vector of `DepNodeIndex`, basically. Contains no duplicates.
1298reads: EdgesVec,
12991300/// When adding a new edge to `reads` in `DepGraph::read_index` we must determine if the edge
1301 /// has been seen before. We just do a linear scan of `reads` if its length is less than or
1302 /// equal to `LINEAR_SCAN_MAX`. Otherwise, we use this hashset for better performance. Note:
1303 /// `reads` is always the canonical edges representation; this field is just to speed up the
1304 /// seen-before test.
1305read_set: FxHashSet<DepNodeIndex>,
1306}
13071308impl TaskDeps {
1309/// See `TaskDeps::read_set` above.
1310const LINEAR_SCAN_MAX: usize = 16;
13111312#[inline]
1313fn new(#[cfg(debug_assertions)] node: Option<DepNode>, read_set_capacity: usize) -> Self {
1314TaskDeps {
1315#[cfg(debug_assertions)]
1316node,
1317 reads: EdgesVec::new(),
1318 read_set: FxHashSet::with_capacity_and_hasher(read_set_capacity, Default::default()),
1319 }
1320 }
1321}
13221323// A data structure that stores Option<DepNodeColor> values as a contiguous
1324// array, using one u32 per entry.
1325pub(super) struct DepNodeColorMap {
1326 values: IndexVec<SerializedDepNodeIndex, AtomicU32>,
1327}
13281329// All values below `COMPRESSED_RED` are green.
1330const COMPRESSED_RED: u32 = u32::MAX - 1;
1331const COMPRESSED_UNKNOWN: u32 = u32::MAX;
13321333impl DepNodeColorMap {
1334fn new(size: usize) -> DepNodeColorMap {
1335if true {
if !(COMPRESSED_RED > DepNodeIndex::MAX_AS_U32) {
::core::panicking::panic("assertion failed: COMPRESSED_RED > DepNodeIndex::MAX_AS_U32")
};
};debug_assert!(COMPRESSED_RED > DepNodeIndex::MAX_AS_U32);
1336DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_UNKNOWN)).collect() }
1337 }
13381339#[inline]
1340pub(super) fn current(&self, index: SerializedDepNodeIndex) -> Option<DepNodeIndex> {
1341let value = self.values[index].load(Ordering::Relaxed);
1342if value <= DepNodeIndex::MAX_AS_U32 { Some(DepNodeIndex::from_u32(value)) } else { None }
1343 }
13441345/// Atomically sets the color of a previous-session dep node to either green
1346 /// or red, if it has not already been colored.
1347 ///
1348 /// If the node already has a color, the new color is ignored, and the
1349 /// return value indicates the existing color.
1350#[inline(always)]
1351pub(super) fn try_set_color(
1352&self,
1353 prev_index: SerializedDepNodeIndex,
1354 color: DesiredColor,
1355 ) -> TrySetColorResult {
1356match self.values[prev_index].compare_exchange(
1357COMPRESSED_UNKNOWN,
1358match color {
1359 DesiredColor::Red => COMPRESSED_RED,
1360 DesiredColor::Green { index } => index.as_u32(),
1361 },
1362 Ordering::Relaxed,
1363 Ordering::Relaxed,
1364 ) {
1365Ok(_) => TrySetColorResult::Success,
1366Err(COMPRESSED_RED) => TrySetColorResult::AlreadyRed,
1367Err(index) => TrySetColorResult::AlreadyGreen { index: DepNodeIndex::from_u32(index) },
1368 }
1369 }
13701371#[inline]
1372pub(super) fn get(&self, index: SerializedDepNodeIndex) -> DepNodeColor {
1373let value = self.values[index].load(Ordering::Acquire);
1374// Green is by far the most common case. Check for that first so we can succeed with a
1375 // single comparison.
1376if value < COMPRESSED_RED {
1377 DepNodeColor::Green(DepNodeIndex::from_u32(value))
1378 } else if value == COMPRESSED_RED {
1379 DepNodeColor::Red1380 } else {
1381if true {
match (&value, &COMPRESSED_UNKNOWN) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
};
};debug_assert_eq!(value, COMPRESSED_UNKNOWN);
1382 DepNodeColor::Unknown1383 }
1384 }
1385}
13861387/// The color that [`DepNodeColorMap::try_set_color`] should try to apply to a node.
1388#[derive(#[automatically_derived]
impl ::core::clone::Clone for DesiredColor {
#[inline]
fn clone(&self) -> DesiredColor {
let _: ::core::clone::AssertParamIsClone<DepNodeIndex>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DesiredColor { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for DesiredColor {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
DesiredColor::Red => ::core::fmt::Formatter::write_str(f, "Red"),
DesiredColor::Green { index: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Green",
"index", &__self_0),
}
}
}Debug)]
1389pub(super) enum DesiredColor {
1390/// Try to mark the node red.
1391Red,
1392/// Try to mark the node green, associating it with a current-session node index.
1393Green { index: DepNodeIndex },
1394}
13951396/// Return value of [`DepNodeColorMap::try_set_color`], indicating success or failure,
1397/// and (on failure) what the existing color is.
1398#[derive(#[automatically_derived]
impl ::core::clone::Clone for TrySetColorResult {
#[inline]
fn clone(&self) -> TrySetColorResult {
let _: ::core::clone::AssertParamIsClone<DepNodeIndex>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TrySetColorResult { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for TrySetColorResult {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TrySetColorResult::Success =>
::core::fmt::Formatter::write_str(f, "Success"),
TrySetColorResult::AlreadyRed =>
::core::fmt::Formatter::write_str(f, "AlreadyRed"),
TrySetColorResult::AlreadyGreen { index: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"AlreadyGreen", "index", &__self_0),
}
}
}Debug)]
1399pub(super) enum TrySetColorResult {
1400/// The [`DesiredColor`] was freshly applied to the node.
1401Success,
1402/// Coloring failed because the node was already marked red.
1403AlreadyRed,
1404/// Coloring failed because the node was already marked green,
1405 /// and corresponds to node `index` in the current-session dep graph.
1406AlreadyGreen { index: DepNodeIndex },
1407}
14081409#[inline(never)]
1410#[cold]
1411pub(crate) fn print_markframe_trace(graph: &DepGraph, frame: &MarkFrame<'_>) {
1412let data = graph.data.as_ref().unwrap();
14131414{
::std::io::_eprint(format_args!("there was a panic while trying to force a dep node\n"));
};eprintln!("there was a panic while trying to force a dep node");
1415{ ::std::io::_eprint(format_args!("try_mark_green dep node stack:\n")); };eprintln!("try_mark_green dep node stack:");
14161417let mut i = 0;
1418let mut current = Some(frame);
1419while let Some(frame) = current {
1420let node = data.previous.index_to_node(frame.index);
1421{ ::std::io::_eprint(format_args!("#{0} {1:?}\n", i, node)); };eprintln!("#{i} {node:?}");
1422 current = frame.parent;
1423 i += 1;
1424 }
14251426{
::std::io::_eprint(format_args!("end of try_mark_green dep node stack\n"));
};eprintln!("end of try_mark_green dep node stack");
1427}
14281429#[cold]
1430#[inline(never)]
1431fn panic_on_forbidden_read(data: &DepGraphData, dep_node_index: DepNodeIndex) -> ! {
1432// We have to do an expensive reverse-lookup of the DepNode that
1433 // corresponds to `dep_node_index`, but that's OK since we are about
1434 // to ICE anyway.
1435let mut dep_node = None;
14361437// First try to find the dep node among those that already existed in the
1438 // previous session and has been marked green
1439for prev_index in data.colors.values.indices() {
1440if data.colors.current(prev_index) == Some(dep_node_index) {
1441 dep_node = Some(*data.previous.index_to_node(prev_index));
1442break;
1443 }
1444 }
14451446let dep_node = dep_node.map_or_else(
1447 || ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("with index {0:?}", dep_node_index))
})format!("with index {:?}", dep_node_index),
1448 |dep_node| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0:?}`", dep_node))
})format!("`{:?}`", dep_node),
1449 );
14501451{
::core::panicking::panic_fmt(format_args!("Error: trying to record dependency on DepNode {0} in a context that does not allow it (e.g. during query deserialization). The most common case of recording a dependency on a DepNode `foo` is when the corresponding query `foo` is invoked. Invoking queries is not allowed as part of loading something from the incremental on-disk cache. See <https://github.com/rust-lang/rust/pull/91919>.",
dep_node));
}panic!(
1452"Error: trying to record dependency on DepNode {dep_node} in a \
1453 context that does not allow it (e.g. during query deserialization). \
1454 The most common case of recording a dependency on a DepNode `foo` is \
1455 when the corresponding query `foo` is invoked. Invoking queries is not \
1456 allowed as part of loading something from the incremental on-disk cache. \
1457 See <https://github.com/rust-lang/rust/pull/91919>."
1458)1459}
14601461impl<'tcx> TyCtxt<'tcx> {
1462/// Return whether this kind always require evaluation.
1463#[inline(always)]
1464fn is_eval_always(self, kind: DepKind) -> bool {
1465self.dep_kind_vtable(kind).is_eval_always
1466 }
1467}