Skip to content

Commit

Permalink
Unrolled build for rust-lang#131686
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#131686 - Urgau:fast-path-vis, r=lqd

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 rust-lang#131111 (comment).

r? `@lqd`
  • Loading branch information
rust-timer authored Oct 16, 2024
2 parents bed75e7 + 67b85e2 commit 246a992
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ use rustc_middle::util::Providers;
use rustc_session::CodegenUnits;
use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath};
use rustc_span::symbol::Symbol;
use rustc_target::spec::SymbolVisibility;
use tracing::debug;

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

fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility {
// Fast-path to avoid expensive query call below
if tcx.sess.default_visibility() == SymbolVisibility::Interposable {
return Visibility::Default;
}

let export_level = if is_generic {
// Generic functions never have export-level C.
SymbolExportLevel::Rust
Expand All @@ -913,6 +919,7 @@ fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibilit
_ => SymbolExportLevel::Rust,
}
};

match export_level {
// C-export level items remain at `Default` to allow C code to
// access and interpose them.
Expand Down

0 comments on commit 246a992

Please sign in to comment.