Skip to content

Commit f0bbf4e

Browse files
incr.comp.: Re-execute queries during red/green marking in order to find out their color.
1 parent 6db27d9 commit f0bbf4e

File tree

6 files changed

+397
-92
lines changed

6 files changed

+397
-92
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ use hir::{HirId, ItemLocalId};
6666

6767
use ich::Fingerprint;
6868
use ty::{TyCtxt, Instance, InstanceDef};
69-
use ty::fast_reject::SimplifiedType;
7069
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
7170
use ich::StableHashingContext;
7271
use std::fmt;
@@ -430,7 +429,6 @@ define_dep_nodes!( <'tcx>
430429
[] RegionScopeTree(DefId),
431430
[] Coherence,
432431
[] CoherenceInherentImplOverlapCheck,
433-
[] Resolve,
434432
[] CoherenceCheckTrait(DefId),
435433
[] PrivacyAccessLevels(CrateNum),
436434

@@ -447,10 +445,8 @@ define_dep_nodes!( <'tcx>
447445
[] MirBorrowCheck(DefId),
448446
[] UnsafetyViolations(DefId),
449447

450-
[] RvalueCheck(DefId),
451448
[] Reachability,
452449
[] MirKeys,
453-
[] TransWriteMetadata,
454450
[] CrateVariances,
455451

456452
// Nodes representing bits of computed IR in the tcx. Each shared
@@ -498,18 +494,9 @@ define_dep_nodes!( <'tcx>
498494

499495
// The set of impls for a given trait.
500496
[] TraitImpls(DefId),
501-
[] RelevantTraitImpls(DefId, SimplifiedType),
502497

503498
[] AllLocalTraitImpls,
504499

505-
// Nodes representing caches. To properly handle a true cache, we
506-
// don't use a DepTrackingMap, but rather we push a task node.
507-
// Otherwise the write into the map would be incorrectly
508-
// attributed to the first task that happened to fill the cache,
509-
// which would yield an overly conservative dep-graph.
510-
[] TraitItems(DefId),
511-
[] ReprHints(DefId),
512-
513500
// Trait selection cache is a little funny. Given a trait
514501
// reference like `Foo: SomeTrait<Bar>`, there could be
515502
// arbitrarily many def-ids to map on in there (e.g., `Foo`,
@@ -598,7 +585,6 @@ define_dep_nodes!( <'tcx>
598585
[] MissingLangItems(CrateNum),
599586
[] ExternConstBody(DefId),
600587
[] VisibleParentMap,
601-
[] IsDirectExternCrate(CrateNum),
602588
[] MissingExternCrateItem(CrateNum),
603589
[] UsedCrateSource(CrateNum),
604590
[] PostorderCnums,
@@ -618,6 +604,9 @@ define_dep_nodes!( <'tcx>
618604
[] CodegenUnit(InternedString),
619605
[] CompileCodegenUnit(InternedString),
620606
[] OutputFilenames,
607+
608+
// We use this for most things when incr. comp. is turned off.
609+
[] Null,
621610
);
622611

623612
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {

src/librustc/dep_graph/graph.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@ impl DepGraph {
460460

461461
let mut current_deps = Vec::new();
462462

463-
for &dep_dep_node in prev_deps {
464-
let dep_dep_node = &data.previous.index_to_node(dep_dep_node);
463+
for &dep_dep_node_index in prev_deps {
464+
let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index);
465+
465466
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
466467
match dep_dep_node_color {
467468
Some(DepNodeColor::Green(node_index)) => {
@@ -478,19 +479,42 @@ impl DepGraph {
478479
return None
479480
}
480481
None => {
482+
if dep_dep_node.kind.is_input() {
483+
// This input does not exist anymore.
484+
debug_assert!(dep_dep_node.extract_def_id(tcx).is_none());
485+
return None;
486+
}
487+
481488
// We don't know the state of this dependency. Let's try to
482489
// mark it green.
483490
if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) {
484491
current_deps.push(node_index);
485492
} else {
486-
// We failed to mark it green. This can have various
487-
// reasons.
488-
return None
493+
// We failed to mark it green, so we try to force the query.
494+
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
495+
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
496+
match dep_dep_node_color {
497+
Some(DepNodeColor::Green(node_index)) => {
498+
current_deps.push(node_index);
499+
}
500+
Some(DepNodeColor::Red) => {
501+
return None
502+
}
503+
None => {
504+
bug!("try_mark_green() - Forcing the DepNode \
505+
should have set its color")
506+
}
507+
}
508+
} else {
509+
// The DepNode could not be forced.
510+
return None
511+
}
489512
}
490513
}
491514
}
492515
}
493516

517+
494518
// If we got here without hitting a `return` that means that all
495519
// dependencies of this DepNode could be marked as green. Therefore we
496520
// can also mark this DepNode as green. We do so by...

src/librustc/ty/maps/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use syntax::symbol::Symbol;
5656
#[macro_use]
5757
mod plumbing;
5858
use self::plumbing::*;
59+
pub use self::plumbing::force_from_dep_node;
5960

6061
mod keys;
6162
pub use self::keys::Key;

0 commit comments

Comments
 (0)