Make force_from_dep_node a function pointer.
This commit is contained in:
parent
bee1fbb67e
commit
921b284167
3 changed files with 90 additions and 110 deletions
|
@ -8,7 +8,6 @@ use rustc_hir::def_id::LocalDefId;
|
|||
|
||||
mod dep_node;
|
||||
|
||||
pub(crate) use rustc_query_system::dep_graph::DepNodeParams;
|
||||
pub use rustc_query_system::dep_graph::{
|
||||
debug, hash_result, DepContext, DepNodeColor, DepNodeIndex, SerializedDepNodeIndex,
|
||||
WorkProduct, WorkProductId,
|
||||
|
@ -155,7 +154,26 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
debug!("try_force_from_dep_node({:?}) --- trying to force", dep_node);
|
||||
ty::query::force_from_dep_node(*self, dep_node)
|
||||
|
||||
// We must avoid ever having to call `force_from_dep_node()` for a
|
||||
// `DepNode::codegen_unit`:
|
||||
// Since we cannot reconstruct the query key of a `DepNode::codegen_unit`, we
|
||||
// would always end up having to evaluate the first caller of the
|
||||
// `codegen_unit` query that *is* reconstructible. This might very well be
|
||||
// the `compile_codegen_unit` query, thus re-codegenning the whole CGU just
|
||||
// to re-trigger calling the `codegen_unit` query with the right key. At
|
||||
// that point we would already have re-done all the work we are trying to
|
||||
// avoid doing in the first place.
|
||||
// The solution is simple: Just explicitly call the `codegen_unit` query for
|
||||
// each CGU, right after partitioning. This way `try_mark_green` will always
|
||||
// hit the cache instead of having to go through `force_from_dep_node`.
|
||||
// This assertion makes sure, we actually keep applying the solution above.
|
||||
debug_assert!(
|
||||
dep_node.kind != DepKind::codegen_unit,
|
||||
"calling force_from_dep_node() on DepKind::codegen_unit"
|
||||
);
|
||||
|
||||
(dep_node.kind.force_from_dep_node)(*self, dep_node)
|
||||
}
|
||||
|
||||
fn has_errors_or_delayed_span_bugs(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue