about summary refs log tree commit diff
path: root/compiler/rustc_query_impl
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-25 21:37:10 +0000
committerbors <bors@rust-lang.org>2022-09-25 21:37:10 +0000
commitff40f2ec95923c4d45366e85bcff17d75df68d68 (patch)
tree32ea6f6e49361168058806d001ae913add2a24a9 /compiler/rustc_query_impl
parentf5193a9fcc73dc09e41a90c5a2c97fc9acc16032 (diff)
parent00cde6d4b94bba23ad06b352bc589805574f62b2 (diff)
downloadrust-ff40f2ec95923c4d45366e85bcff17d75df68d68.tar.gz
rust-ff40f2ec95923c4d45366e85bcff17d75df68d68.zip
Auto merge of #101710 - jyn514:move-dep-kind-node, r=cjgillot
Move DepKindStruct from rustc_middle to rustc_query_system

Helps with https://github.com/rust-lang/rust/issues/96524. cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60DepKindStruct.60.20to.20rustc_query_system.20.2396524

r? `@cjgillot`
Diffstat (limited to 'compiler/rustc_query_impl')
-rw-r--r--compiler/rustc_query_impl/src/plumbing.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs
index d819f4774d5..ac95c8edf3f 100644
--- a/compiler/rustc_query_impl/src/plumbing.rs
+++ b/compiler/rustc_query_impl/src/plumbing.rs
@@ -380,6 +380,24 @@ where
     Q::Key: DepNodeParams<TyCtxt<'tcx>>,
     Q::Value: Value<TyCtxt<'tcx>>,
 {
+    // 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"
+    );
+
     if let Some(key) = Q::Key::recover(tcx, &dep_node) {
         #[cfg(debug_assertions)]
         let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();