Skip to content

Commit 701880a

Browse files
committed
Auto merge of #131686 - Urgau:fast-path-vis, r=<try>
Add fast-path when computing the default visibility This PR adds (or more correctly re-adds the) fast-path when computing the default visibility, by taking advantage of the fact that the "interposable" requested visibility always return the "default" codegen visibility. Should address the small regression observed in #131111 (comment). r? `@lqd`
2 parents f6648f2 + 67b85e2 commit 701880a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: compiler/rustc_monomorphize/src/partitioning.rs

+7
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ use rustc_middle::util::Providers;
119119
use rustc_session::CodegenUnits;
120120
use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath};
121121
use rustc_span::symbol::Symbol;
122+
use rustc_target::spec::SymbolVisibility;
122123
use tracing::debug;
123124

124125
use crate::collector::{self, MonoItemCollectionStrategy, UsageMap};
@@ -904,6 +905,11 @@ fn mono_item_visibility<'tcx>(
904905
}
905906

906907
fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility {
908+
// Fast-path to avoid expensive query call below
909+
if tcx.sess.default_visibility() == SymbolVisibility::Interposable {
910+
return Visibility::Default;
911+
}
912+
907913
let export_level = if is_generic {
908914
// Generic functions never have export-level C.
909915
SymbolExportLevel::Rust
@@ -913,6 +919,7 @@ fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibilit
913919
_ => SymbolExportLevel::Rust,
914920
}
915921
};
922+
916923
match export_level {
917924
// C-export level items remain at `Default` to allow C code to
918925
// access and interpose them.

0 commit comments

Comments
 (0)