Skip to content

Commit c89aba5

Browse files
committed
[DO NOT MERGE] Check performance hit of emitting full metadata in check mode
1 parent cc3eee7 commit c89aba5

File tree

4 files changed

+4
-36
lines changed

4 files changed

+4
-36
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,11 +1836,6 @@ fn exported_symbols_for_non_proc_macro(
18361836
}
18371837

18381838
fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> {
1839-
// `exported_symbols` will be empty when !should_codegen.
1840-
if !tcx.sess.opts.output_types.should_codegen() {
1841-
return Vec::new();
1842-
}
1843-
18441839
let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE);
18451840
let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
18461841

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel {
4747
}
4848

4949
fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<SymbolExportInfo> {
50-
if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() {
51-
return Default::default();
52-
}
53-
5450
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
5551

5652
let mut reachable_non_generics: DefIdMap<_> = tcx
@@ -166,10 +162,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
166162
tcx: TyCtxt<'tcx>,
167163
_: LocalCrate,
168164
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
169-
if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() {
170-
return &[];
171-
}
172-
173165
// FIXME: Sorting this is unnecessary since we are sorting later anyway.
174166
// Can we skip the later sorting?
175167
let sorted = tcx.with_stable_hashing_context(|hcx| {
@@ -221,10 +213,6 @@ fn exported_generic_symbols_provider_local<'tcx>(
221213
tcx: TyCtxt<'tcx>,
222214
_: LocalCrate,
223215
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
224-
if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() {
225-
return &[];
226-
}
227-
228216
let mut symbols: Vec<_> = vec![];
229217

230218
if tcx.local_crate_exports_generics() {

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,9 +1114,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11141114
// If we need to codegen, ensure that we emit all errors from
11151115
// `mir_drops_elaborated_and_const_checked` now, to avoid discovering
11161116
// them later during codegen.
1117-
if tcx.sess.opts.output_types.should_codegen()
1118-
|| tcx.hir_body_const_context(def_id).is_some()
1119-
{
1117+
if tcx.hir_body_const_context(def_id).is_some() {
11201118
tcx.ensure_ok().mir_drops_elaborated_and_const_checked(def_id);
11211119
}
11221120
if tcx.is_coroutine(def_id.to_def_id()) {

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,11 +1111,7 @@ fn should_encode_mir(
11111111
) -> (bool, bool) {
11121112
match tcx.def_kind(def_id) {
11131113
// Constructors
1114-
DefKind::Ctor(_, _) => {
1115-
let mir_opt_base = tcx.sess.opts.output_types.should_codegen()
1116-
|| tcx.sess.opts.unstable_opts.always_encode_mir;
1117-
(true, mir_opt_base)
1118-
}
1114+
DefKind::Ctor(_, _) => (true, true),
11191115
// Constants
11201116
DefKind::AnonConst | DefKind::InlineConst | DefKind::AssocConst | DefKind::Const => {
11211117
(true, false)
@@ -1127,8 +1123,7 @@ fn should_encode_mir(
11271123
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
11281124
let generics = tcx.generics_of(def_id);
11291125
let opt = tcx.sess.opts.unstable_opts.always_encode_mir
1130-
|| (tcx.sess.opts.output_types.should_codegen()
1131-
&& reachable_set.contains(&def_id)
1126+
|| (reachable_set.contains(&def_id)
11321127
&& (generics.requires_monomorphization(tcx)
11331128
|| tcx.cross_crate_inlinable(def_id)));
11341129
// The function has a `const` modifier or is in a `const trait`.
@@ -1858,10 +1853,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18581853
// Encode all the deduced parameter attributes for everything that has MIR, even for items
18591854
// that can't be inlined. But don't if we aren't optimizing in non-incremental mode, to
18601855
// save the query traffic.
1861-
if tcx.sess.opts.output_types.should_codegen()
1862-
&& tcx.sess.opts.optimize != OptLevel::No
1863-
&& tcx.sess.opts.incremental.is_none()
1864-
{
1856+
if tcx.sess.opts.optimize != OptLevel::No && tcx.sess.opts.incremental.is_none() {
18651857
for &local_def_id in tcx.mir_keys(()) {
18661858
if let DefKind::AssocFn | DefKind::Fn = tcx.def_kind(local_def_id) {
18671859
record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <-
@@ -2263,11 +2255,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
22632255
/// Used to prefetch queries which will be needed later by metadata encoding.
22642256
/// Only a subset of the queries are actually prefetched to keep this code smaller.
22652257
fn prefetch_mir(tcx: TyCtxt<'_>) {
2266-
if !tcx.sess.opts.output_types.should_codegen() {
2267-
// We won't emit MIR, so don't prefetch it.
2268-
return;
2269-
}
2270-
22712258
let reachable_set = tcx.reachable_set(());
22722259
par_for_each_in(tcx.mir_keys(()), |&&def_id| {
22732260
if tcx.is_trivial_const(def_id) {

0 commit comments

Comments
 (0)