metadata: record unused_generic_params
This commit records the results of `unused_generic_params` in crate metadata, hopefully improving performance. Signed-off-by: David Wood <david@davidtw.co>
This commit is contained in:
parent
f52c72948a
commit
5ce29d3d6f
@ -1132,6 +1132,16 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
.decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_unused_generic_params(&self, id: DefIndex) -> u64 {
|
||||
self.root
|
||||
.tables
|
||||
.unused_generic_params
|
||||
.get(self, id)
|
||||
.filter(|_| !self.is_proc_macro(id))
|
||||
.map(|params| params.decode(self))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> IndexVec<Promoted, Body<'tcx>> {
|
||||
self.root
|
||||
.tables
|
||||
|
@ -113,6 +113,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
}
|
||||
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
|
||||
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
|
||||
unused_generic_params => { cdata.get_unused_generic_params(def_id.index) }
|
||||
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
||||
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
|
||||
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
|
||||
|
@ -1065,6 +1065,8 @@ impl EncodeContext<'tcx> {
|
||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
|
||||
record!(self.tables.mir[def_id.to_def_id()] <- self.tcx.optimized_mir(def_id));
|
||||
record!(self.tables.unused_generic_params[def_id.to_def_id()] <-
|
||||
self.tcx.unused_generic_params(def_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,6 +277,7 @@ define_tables! {
|
||||
super_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||
mir: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
||||
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
|
||||
unused_generic_params: Table<DefIndex, Lazy<u64>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user