32
32
//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
33
33
//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
34
34
//! needed at runtime in order to construct a valid `DepNode` fingerprint.
35
- //! However, only `CompileCodegenUnit` is constructed explicitly (with
36
- //! `make_compile_codegen_unit`).
35
+ //! However, only `CompileCodegenUnit` and `CompileMonoItem` are constructed
36
+ //! explicitly (with `make_compile_codegen_unit` cq `make_compile_mono_item `).
37
37
//!
38
38
//! Because the macro sees what parameters a given `DepKind` requires, it can
39
39
//! "infer" some properties for each kind of `DepNode`:
46
46
//! `DefId` it was computed from. In other cases, too much information gets
47
47
//! lost during fingerprint computation.
48
48
//!
49
- //! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
50
- //! valid `DepNode` instances can be constructed. For example, the API does not
51
- //! allow for constructing parameterless `DepNode`s with anything other
52
- //! than a zeroed out fingerprint. More generally speaking, it relieves the
53
- //! user of the `DepNode` API of having to know how to compute the expected
54
- //! fingerprint for a given set of node parameters.
49
+ //! `make_compile_codegen_unit` and `make_compile_mono_items`, together with
50
+ //! `DepNode::new()`, ensures that only valid `DepNode` instances can be
51
+ //! constructed. For example, the API does not allow for constructing
52
+ //! parameterless `DepNode`s with anything other than a zeroed out fingerprint.
53
+ //! More generally speaking, it relieves the user of the `DepNode` API of
54
+ //! having to know how to compute the expected fingerprint for a given set of
55
+ //! node parameters.
55
56
//!
56
57
//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html
57
58
59
+ use crate :: mir:: mono:: MonoItem ;
58
60
use crate :: ty:: TyCtxt ;
59
61
60
62
use rustc_data_structures:: fingerprint:: Fingerprint ;
@@ -175,6 +177,14 @@ pub mod dep_kind {
175
177
can_reconstruct_query_key : || false ,
176
178
} ;
177
179
180
+ pub const CompileMonoItem : DepKindStruct = DepKindStruct {
181
+ has_params : true ,
182
+ is_anon : false ,
183
+ is_eval_always : false ,
184
+
185
+ can_reconstruct_query_key : || false ,
186
+ } ;
187
+
178
188
macro_rules! define_query_dep_kinds {
179
189
( $(
180
190
[ $( $attrs: tt) * ]
@@ -251,6 +261,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
251
261
252
262
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
253
263
[ ] CompileCodegenUnit ( Symbol ) ,
264
+
265
+ // WARNING: if `MonoItem` is changed, make sure you update `make_compile_mono_item` below.
266
+ // Only used by rustc_codegen_cranelift
267
+ [ ] CompileMonoItem ( MonoItem ) ,
254
268
] ) ;
255
269
256
270
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
@@ -259,6 +273,12 @@ crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
259
273
DepNode :: construct ( tcx, DepKind :: CompileCodegenUnit , & name)
260
274
}
261
275
276
+ // WARNING: `construct` is generic and does not know that `CompileMonoItem` takes `MonoItem`s as keys.
277
+ // Be very careful changing this type signature!
278
+ crate fn make_compile_mono_item ( tcx : TyCtxt < ' tcx > , mono_item : & MonoItem < ' tcx > ) -> DepNode {
279
+ DepNode :: construct ( tcx, DepKind :: CompileMonoItem , mono_item)
280
+ }
281
+
262
282
pub type DepNode = rustc_query_system:: dep_graph:: DepNode < DepKind > ;
263
283
264
284
// We keep a lot of `DepNode`s in memory during compilation. It's not
0 commit comments