diff options
| author | David Wood <david@davidtw.co> | 2020-08-04 18:16:39 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2020-08-04 20:09:29 +0100 |
| commit | 70b49c7bddec33e6972610e024fcbb3576aa9be3 (patch) | |
| tree | 06e73a7c4272fbbb4761889263099b558038c327 | |
| parent | 5f89f02c4e7d06dcb94434b8b30ce457b06eda5c (diff) | |
| download | rust-70b49c7bddec33e6972610e024fcbb3576aa9be3.tar.gz rust-70b49c7bddec33e6972610e024fcbb3576aa9be3.zip | |
metadata: skip empty polymorphization bitset
This commit skips encoding empty polymorphization results - while polymorphization is disabled, this should be every polymorphization result; but when polymorphization is re-enabled, this would help with non-generic functions and those which do use all their parameters (most functions). Signed-off-by: David Wood <david@davidtw.co>
| -rw-r--r-- | src/librustc_metadata/rmeta/encoder.rs | 7 | ||||
| -rw-r--r-- | src/librustc_mir/monomorphize/polymorphize.rs | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 352b8bff7e2..aec9e8daa0f 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -1134,8 +1134,11 @@ impl EncodeContext<'a, '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)); + + let unused = self.tcx.unused_generic_params(def_id); + if !unused.is_empty() { + record!(self.tables.unused_generic_params[def_id.to_def_id()] <- unused); + } } } diff --git a/src/librustc_mir/monomorphize/polymorphize.rs b/src/librustc_mir/monomorphize/polymorphize.rs index 505cef5e9fc..8fc1458f592 100644 --- a/src/librustc_mir/monomorphize/polymorphize.rs +++ b/src/librustc_mir/monomorphize/polymorphize.rs @@ -36,6 +36,13 @@ fn unused_generic_params(tcx: TyCtxt<'_>, def_id: DefId) -> FiniteBitSet<u32> { return FiniteBitSet::new_empty(); } + // Polymorphization results are stored in cross-crate metadata only when there are unused + // parameters, so assume that non-local items must have only used parameters (else this query + // would not be invoked, and the cross-crate metadata used instead). + if !def_id.is_local() { + return FiniteBitSet::new_empty(); + } + let generics = tcx.generics_of(def_id); debug!("unused_generic_params: generics={:?}", generics); |
