Skip to content

Commit 12cdef6

Browse files
Rollup merge of #153561 - Zalathar:try-mark-green, r=nnethercote
Replace the `try_mark_green` hook with direct calls to `tcx.dep_graph` All of the existing call sites are directly touching `tcx.dep_graph` anyway, so the extra layer of indirection provides no real benefit. There should be no change to compiler behaviour. r? nnethercote (or compiler)
2 parents af3e256 + 0a369a7 commit 12cdef6

7 files changed

Lines changed: 5 additions & 14 deletions

File tree

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ pub fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) ->
11181118
)
11191119
});
11201120

1121-
if tcx.try_mark_green(&dep_node) {
1121+
if tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some() {
11221122
// We can re-use either the pre- or the post-thinlto state. If no LTO is
11231123
// being performed then we can use post-LTO artifacts, otherwise we must
11241124
// reuse pre-LTO artifacts

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: Option<&Path>) {
24432443
if tcx.dep_graph.is_fully_enabled()
24442444
&& let work_product_id = WorkProductId::from_cgu_name("metadata")
24452445
&& let Some(work_product) = tcx.dep_graph.previous_work_product(&work_product_id)
2446-
&& tcx.try_mark_green(&dep_node)
2446+
&& tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some()
24472447
{
24482448
let saved_path = &work_product.saved_files["rmeta"];
24492449
let incr_comp_session_dir = tcx.sess.incr_comp_session_dir_opt().unwrap();

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ impl DepGraph {
882882
tcx: TyCtxt<'tcx>,
883883
dep_node: &DepNode,
884884
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
885-
self.data().and_then(|data| data.try_mark_green(tcx, dep_node))
885+
self.data()?.try_mark_green(tcx, dep_node)
886886
}
887887
}
888888

compiler/rustc_middle/src/hooks/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ declare_hooks! {
109109
/// Creates the MIR for a given `DefId`, including unreachable code.
110110
hook build_mir_inner_impl(def: LocalDefId) -> mir::Body<'tcx>;
111111

112-
hook try_mark_green(dep_node: &crate::dep_graph::DepNode) -> bool;
113-
114112
hook encode_all_query_results(
115113
encoder: &mut CacheEncoder<'_, 'tcx>,
116114
query_result_index: &mut EncodedDepNodeIndex

compiler/rustc_query_impl/src/execution.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,7 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
628628

629629
let dep_node = DepNode::construct(tcx, query.dep_kind, &key);
630630

631-
let dep_graph = &tcx.dep_graph;
632-
let serialized_dep_node_index = match dep_graph.try_mark_green(tcx, &dep_node) {
631+
let serialized_dep_node_index = match tcx.dep_graph.try_mark_green(tcx, &dep_node) {
633632
None => {
634633
// A None return from `try_mark_green` means that this is either
635634
// a new dep node or that the dep node has already been marked red.
@@ -640,7 +639,7 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
640639
return EnsureCanSkip { skip_execution: false, dep_node: Some(dep_node) };
641640
}
642641
Some((serialized_dep_node_index, dep_node_index)) => {
643-
dep_graph.read_index(dep_node_index);
642+
tcx.dep_graph.read_index(dep_node_index);
644643
tcx.prof.query_cache_hit(dep_node_index.into());
645644
serialized_dep_node_index
646645
}

compiler/rustc_query_impl/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_span::Span;
2020
pub use crate::dep_kind_vtables::make_dep_kind_vtables;
2121
use crate::from_cycle_error::FromCycleError;
2222
pub use crate::job::{QueryJobMap, break_query_cycles, print_query_stack};
23-
use crate::plumbing::try_mark_green;
2423
use crate::profiling_support::QueryKeyStringCache;
2524

2625
#[macro_use]
@@ -69,5 +68,4 @@ pub fn provide(providers: &mut rustc_middle::util::Providers) {
6968
providers.hooks.alloc_self_profile_query_strings = alloc_self_profile_query_strings;
7069
providers.hooks.query_key_hash_verify_all = query_key_hash_verify_all;
7170
providers.hooks.encode_all_query_results = encode_all_query_results;
72-
providers.hooks.try_mark_green = try_mark_green;
7371
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ pub(crate) fn start_query<R>(
9090
})
9191
}
9292

93-
pub(super) fn try_mark_green<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool {
94-
tcx.dep_graph.try_mark_green(tcx, dep_node).is_some()
95-
}
96-
9793
/// The deferred part of a deferred query stack frame.
9894
fn mk_query_stack_frame_extra<'tcx, Cache>(
9995
(tcx, vtable, key): (TyCtxt<'tcx>, &'tcx QueryVTable<'tcx, Cache>, Cache::Key),

0 commit comments

Comments
 (0)