Skip to content

Commit efd0483

Browse files
committed
Auto merge of #89978 - cjgillot:qarray, r=Mark-Simulacrum
Merge the two depkind vtables Knowledge of `DepKind`s is managed using two arrays containing flags (is_anon, eval_always, fingerprint_style), and function pointers (forcing and loading code). This PR aims at merging the two arrays so as to reduce unneeded indirect calls and (hopefully) increase code locality. r? `@ghost`
2 parents 3d71e74 + b11ec29 commit efd0483

File tree

22 files changed

+420
-538
lines changed

22 files changed

+420
-538
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4319,7 +4319,6 @@ dependencies = [
43194319
"rustc_serialize",
43204320
"rustc_session",
43214321
"rustc_span",
4322-
"tracing",
43234322
]
43244323

43254324
[[package]]

compiler/rustc_codegen_cranelift/src/driver/aot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub(crate) fn run_aot(
224224
tcx,
225225
(backend_config.clone(), cgu.name()),
226226
module_codegen,
227-
rustc_middle::dep_graph::hash_result,
227+
Some(rustc_middle::dep_graph::hash_result),
228228
);
229229

230230
if let Some((id, product)) = work_product {

compiler/rustc_codegen_gcc/src/base.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (Modul
5959
let start_time = Instant::now();
6060

6161
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
62-
let (module, _) = tcx.dep_graph.with_task(dep_node, tcx, cgu_name, module_codegen, dep_graph::hash_result);
62+
let (module, _) = tcx.dep_graph.with_task(
63+
dep_node,
64+
tcx,
65+
cgu_name,
66+
module_codegen,
67+
Some(dep_graph::hash_result),
68+
);
6369
let time_to_codegen = start_time.elapsed();
6470
drop(prof_timer);
6571

compiler/rustc_codegen_llvm/src/base.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,13 @@ pub fn compile_codegen_unit(
113113
let start_time = Instant::now();
114114

115115
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
116-
let (module, _) =
117-
tcx.dep_graph.with_task(dep_node, tcx, cgu_name, module_codegen, dep_graph::hash_result);
116+
let (module, _) = tcx.dep_graph.with_task(
117+
dep_node,
118+
tcx,
119+
cgu_name,
120+
module_codegen,
121+
Some(dep_graph::hash_result),
122+
);
118123
let time_to_codegen = start_time.elapsed();
119124

120125
// We assume that the cost to run LLVM on a CGU is proportional to

compiler/rustc_incremental/src/assert_dep_graph.rs

+23-17
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,36 @@ impl IfThisChanged<'tcx> {
126126
if attr.has_name(sym::rustc_if_this_changed) {
127127
let dep_node_interned = self.argument(attr);
128128
let dep_node = match dep_node_interned {
129-
None => DepNode::from_def_path_hash(def_path_hash, DepKind::hir_owner),
130-
Some(n) => match DepNode::from_label_string(&n.as_str(), def_path_hash) {
131-
Ok(n) => n,
132-
Err(()) => {
133-
self.tcx.sess.span_fatal(
134-
attr.span,
135-
&format!("unrecognized DepNode variant {:?}", n),
136-
);
129+
None => {
130+
DepNode::from_def_path_hash(self.tcx, def_path_hash, DepKind::hir_owner)
131+
}
132+
Some(n) => {
133+
match DepNode::from_label_string(self.tcx, &n.as_str(), def_path_hash) {
134+
Ok(n) => n,
135+
Err(()) => {
136+
self.tcx.sess.span_fatal(
137+
attr.span,
138+
&format!("unrecognized DepNode variant {:?}", n),
139+
);
140+
}
137141
}
138-
},
142+
}
139143
};
140144
self.if_this_changed.push((attr.span, def_id.to_def_id(), dep_node));
141145
} else if attr.has_name(sym::rustc_then_this_would_need) {
142146
let dep_node_interned = self.argument(attr);
143147
let dep_node = match dep_node_interned {
144-
Some(n) => match DepNode::from_label_string(&n.as_str(), def_path_hash) {
145-
Ok(n) => n,
146-
Err(()) => {
147-
self.tcx.sess.span_fatal(
148-
attr.span,
149-
&format!("unrecognized DepNode variant {:?}", n),
150-
);
148+
Some(n) => {
149+
match DepNode::from_label_string(self.tcx, &n.as_str(), def_path_hash) {
150+
Ok(n) => n,
151+
Err(()) => {
152+
self.tcx.sess.span_fatal(
153+
attr.span,
154+
&format!("unrecognized DepNode variant {:?}", n),
155+
);
156+
}
151157
}
152-
},
158+
}
153159
None => {
154160
self.tcx.sess.span_fatal(attr.span, "missing DepNode variant");
155161
}

compiler/rustc_incremental/src/persist/dirty_clean.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use rustc_ast::{self as ast, Attribute, NestedMetaItem};
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_hir as hir;
18-
use rustc_hir::def_id::{DefId, LocalDefId};
18+
use rustc_hir::def_id::LocalDefId;
1919
use rustc_hir::intravisit;
2020
use rustc_hir::itemlikevisit::ItemLikeVisitor;
2121
use rustc_hir::Node as HirNode;
@@ -302,18 +302,6 @@ impl DirtyCleanVisitor<'tcx> {
302302
out
303303
}
304304

305-
fn dep_nodes<'l>(
306-
&self,
307-
labels: &'l Labels,
308-
def_id: DefId,
309-
) -> impl Iterator<Item = DepNode> + 'l {
310-
let def_path_hash = self.tcx.def_path_hash(def_id);
311-
labels.iter().map(move |label| match DepNode::from_label_string(label, def_path_hash) {
312-
Ok(dep_node) => dep_node,
313-
Err(()) => unreachable!("label: {}", label),
314-
})
315-
}
316-
317305
fn dep_node_str(&self, dep_node: &DepNode) -> String {
318306
if let Some(def_id) = dep_node.extract_def_id(self.tcx) {
319307
format!("{:?}({})", dep_node.kind, self.tcx.def_path_str(def_id))
@@ -345,16 +333,19 @@ impl DirtyCleanVisitor<'tcx> {
345333
}
346334

347335
fn check_item(&mut self, item_id: LocalDefId, item_span: Span) {
336+
let def_path_hash = self.tcx.def_path_hash(item_id.to_def_id());
348337
for attr in self.tcx.get_attrs(item_id.to_def_id()).iter() {
349338
let assertion = match self.assertion_maybe(item_id, attr) {
350339
Some(a) => a,
351340
None => continue,
352341
};
353342
self.checked_attrs.insert(attr.id);
354-
for dep_node in self.dep_nodes(&assertion.clean, item_id.to_def_id()) {
343+
for label in assertion.clean {
344+
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
355345
self.assert_clean(item_span, dep_node);
356346
}
357-
for dep_node in self.dep_nodes(&assertion.dirty, item_id.to_def_id()) {
347+
for label in assertion.dirty {
348+
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
358349
self.assert_dirty(item_span, dep_node);
359350
}
360351
}

compiler/rustc_interface/src/passes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ pub fn create_global_ctxt<'tcx>(
838838
dep_graph,
839839
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
840840
queries.as_dyn(),
841+
rustc_query_impl::query_callbacks(arena),
841842
crate_name,
842843
outputs,
843844
)

compiler/rustc_middle/src/arena.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ macro_rules! arena_types {
100100
// This is used to decode the &'tcx [Span] for InlineAsm's line_spans.
101101
[decode] span: rustc_span::Span,
102102
[decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
103+
104+
[] dep_kind: rustc_middle::dep_graph::DepKindStruct,
103105
], $tcx);
104106
)
105107
}

0 commit comments

Comments
 (0)