提交 f0bbf4e1 编写于 作者: M Michael Woerister

incr.comp.: Re-execute queries during red/green marking in order to find out their color.

上级 6db27d9f
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
use ich::Fingerprint; use ich::Fingerprint;
use ty::{TyCtxt, Instance, InstanceDef}; use ty::{TyCtxt, Instance, InstanceDef};
use ty::fast_reject::SimplifiedType;
use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
use ich::StableHashingContext; use ich::StableHashingContext;
use std::fmt; use std::fmt;
...@@ -430,7 +429,6 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool { ...@@ -430,7 +429,6 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[] RegionScopeTree(DefId), [] RegionScopeTree(DefId),
[] Coherence, [] Coherence,
[] CoherenceInherentImplOverlapCheck, [] CoherenceInherentImplOverlapCheck,
[] Resolve,
[] CoherenceCheckTrait(DefId), [] CoherenceCheckTrait(DefId),
[] PrivacyAccessLevels(CrateNum), [] PrivacyAccessLevels(CrateNum),
...@@ -447,10 +445,8 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool { ...@@ -447,10 +445,8 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[] MirBorrowCheck(DefId), [] MirBorrowCheck(DefId),
[] UnsafetyViolations(DefId), [] UnsafetyViolations(DefId),
[] RvalueCheck(DefId),
[] Reachability, [] Reachability,
[] MirKeys, [] MirKeys,
[] TransWriteMetadata,
[] CrateVariances, [] CrateVariances,
// Nodes representing bits of computed IR in the tcx. Each shared // Nodes representing bits of computed IR in the tcx. Each shared
...@@ -498,18 +494,9 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool { ...@@ -498,18 +494,9 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
// The set of impls for a given trait. // The set of impls for a given trait.
[] TraitImpls(DefId), [] TraitImpls(DefId),
[] RelevantTraitImpls(DefId, SimplifiedType),
[] AllLocalTraitImpls, [] AllLocalTraitImpls,
// Nodes representing caches. To properly handle a true cache, we
// don't use a DepTrackingMap, but rather we push a task node.
// Otherwise the write into the map would be incorrectly
// attributed to the first task that happened to fill the cache,
// which would yield an overly conservative dep-graph.
[] TraitItems(DefId),
[] ReprHints(DefId),
// Trait selection cache is a little funny. Given a trait // Trait selection cache is a little funny. Given a trait
// reference like `Foo: SomeTrait<Bar>`, there could be // reference like `Foo: SomeTrait<Bar>`, there could be
// arbitrarily many def-ids to map on in there (e.g., `Foo`, // arbitrarily many def-ids to map on in there (e.g., `Foo`,
...@@ -598,7 +585,6 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool { ...@@ -598,7 +585,6 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[] MissingLangItems(CrateNum), [] MissingLangItems(CrateNum),
[] ExternConstBody(DefId), [] ExternConstBody(DefId),
[] VisibleParentMap, [] VisibleParentMap,
[] IsDirectExternCrate(CrateNum),
[] MissingExternCrateItem(CrateNum), [] MissingExternCrateItem(CrateNum),
[] UsedCrateSource(CrateNum), [] UsedCrateSource(CrateNum),
[] PostorderCnums, [] PostorderCnums,
...@@ -618,6 +604,9 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool { ...@@ -618,6 +604,9 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[] CodegenUnit(InternedString), [] CodegenUnit(InternedString),
[] CompileCodegenUnit(InternedString), [] CompileCodegenUnit(InternedString),
[] OutputFilenames, [] OutputFilenames,
// We use this for most things when incr. comp. is turned off.
[] Null,
); );
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
......
...@@ -460,8 +460,9 @@ pub fn try_mark_green(&self, ...@@ -460,8 +460,9 @@ pub fn try_mark_green(&self,
let mut current_deps = Vec::new(); let mut current_deps = Vec::new();
for &dep_dep_node in prev_deps { for &dep_dep_node_index in prev_deps {
let dep_dep_node = &data.previous.index_to_node(dep_dep_node); let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index);
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned(); let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color { match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => { Some(DepNodeColor::Green(node_index)) => {
...@@ -478,19 +479,42 @@ pub fn try_mark_green(&self, ...@@ -478,19 +479,42 @@ pub fn try_mark_green(&self,
return None return None
} }
None => { None => {
if dep_dep_node.kind.is_input() {
// This input does not exist anymore.
debug_assert!(dep_dep_node.extract_def_id(tcx).is_none());
return None;
}
// We don't know the state of this dependency. Let's try to // We don't know the state of this dependency. Let's try to
// mark it green. // mark it green.
if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) { if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) {
current_deps.push(node_index); current_deps.push(node_index);
} else { } else {
// We failed to mark it green. This can have various // We failed to mark it green, so we try to force the query.
// reasons. if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
return None let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => {
current_deps.push(node_index);
}
Some(DepNodeColor::Red) => {
return None
}
None => {
bug!("try_mark_green() - Forcing the DepNode \
should have set its color")
}
}
} else {
// The DepNode could not be forced.
return None
}
} }
} }
} }
} }
// If we got here without hitting a `return` that means that all // If we got here without hitting a `return` that means that all
// dependencies of this DepNode could be marked as green. Therefore we // dependencies of this DepNode could be marked as green. Therefore we
// can also mark this DepNode as green. We do so by... // can also mark this DepNode as green. We do so by...
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#[macro_use] #[macro_use]
mod plumbing; mod plumbing;
use self::plumbing::*; use self::plumbing::*;
pub use self::plumbing::force_from_dep_node;
mod keys; mod keys;
pub use self::keys::Key; pub use self::keys::Key;
......
此差异已折叠。
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
use rustc::mir::Mir; use rustc::mir::Mir;
use rustc::mir::transform::{MirPassIndex, MirSuite, MirSource, use rustc::mir::transform::{MirPassIndex, MirSuite, MirSource,
MIR_CONST, MIR_VALIDATED, MIR_OPTIMIZED}; MIR_CONST, MIR_VALIDATED, MIR_OPTIMIZED};
use rustc::ty::{self, TyCtxt}; use rustc::ty::TyCtxt;
use rustc::ty::maps::Providers; use rustc::ty::maps::Providers;
use rustc::ty::steal::Steal; use rustc::ty::steal::Steal;
use rustc::hir; use rustc::hir;
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
use rustc::util::nodemap::DefIdSet; use rustc::util::nodemap::DefIdSet;
use std::rc::Rc; use std::rc::Rc;
use syntax::ast; use syntax::ast;
use syntax_pos::{DUMMY_SP, Span}; use syntax_pos::Span;
use transform; use transform;
pub mod add_validation; pub mod add_validation;
...@@ -114,11 +114,10 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ...@@ -114,11 +114,10 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
let source = MirSource::from_local_def_id(tcx, def_id); let source = MirSource::from_local_def_id(tcx, def_id);
if let MirSource::Const(_) = source { if let MirSource::Const(_) = source {
// Ensure that we compute the `mir_const_qualif` for constants at // Ensure that we compute the `mir_const_qualif` for constants at
// this point, before we steal the mir-const result. We don't // this point, before we steal the mir-const result.
// directly need the result or `mir_const_qualif`, so we can just force it. let _ = tcx.mir_const_qualif(def_id);
ty::queries::mir_const_qualif::force(tcx, DUMMY_SP, def_id);
} }
ty::queries::unsafety_violations::force(tcx, DUMMY_SP, def_id); let _ = tcx.unsafety_violations(def_id);
let mut mir = tcx.mir_const(def_id).steal(); let mut mir = tcx.mir_const(def_id).steal();
transform::run_suite(tcx, source, MIR_VALIDATED, &mut mir); transform::run_suite(tcx, source, MIR_VALIDATED, &mut mir);
...@@ -128,8 +127,8 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ...@@ -128,8 +127,8 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Mir<'tcx> { fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Mir<'tcx> {
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to // (Mir-)Borrowck uses `mir_validated`, so we have to force it to
// execute before we can steal. // execute before we can steal.
ty::queries::mir_borrowck::force(tcx, DUMMY_SP, def_id); let _ = tcx.mir_borrowck(def_id);
ty::queries::borrowck::force(tcx, DUMMY_SP, def_id); let _ = tcx.borrowck(def_id);
let mut mir = tcx.mir_validated(def_id).steal(); let mut mir = tcx.mir_validated(def_id).steal();
let source = MirSource::from_local_def_id(tcx, def_id); let source = MirSource::from_local_def_id(tcx, def_id);
......
...@@ -947,6 +947,19 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ...@@ -947,6 +947,19 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
shared_ccx.tcx().collect_and_partition_translation_items(LOCAL_CRATE).1; shared_ccx.tcx().collect_and_partition_translation_items(LOCAL_CRATE).1;
let codegen_units = (*codegen_units).clone(); let codegen_units = (*codegen_units).clone();
// Force all codegen_unit queries so they are already either red or green
// when compile_codegen_unit accesses them. We are not able to re-execute
// the codegen_unit query from just the DepNode, so an unknown color would
// lead to having to re-execute compile_codegen_unit, possibly
// unnecessarily.
if tcx.dep_graph.is_fully_enabled() {
for cgu in &codegen_units {
tcx.codegen_unit(cgu.name().clone());
}
}
assert!(codegen_units.len() <= 1 || !tcx.sess.lto());
let ongoing_translation = write::start_async_translation( let ongoing_translation = write::start_async_translation(
tcx, tcx,
time_graph.clone(), time_graph.clone(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册