Skip to content

Commit

Permalink
Auto merge of #113382 - lqd:test-mcp510, r=<try>
Browse files Browse the repository at this point in the history
[perf] test MCP510

r? `@ghost`
  • Loading branch information
bors committed Sep 6, 2024
2 parents d678b81 + 3fcb375 commit 8303600
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_gcc/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ fn create_wrapper_function(
if tcx.sess.default_hidden_visibility() {
#[cfg(feature = "master")]
func.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
} else {
#[cfg(feature = "master")]
func.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Protected));
}
if tcx.sess.must_emit_unwind_tables() {
// TODO(antoyo): emit unwind tables.
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub(crate) unsafe fn codegen(
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
if tcx.sess.default_hidden_visibility() {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
} else {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Protected);
}
let val = tcx.sess.opts.unstable_opts.oom.should_panic();
let llval = llvm::LLVMConstInt(i8, val as u64, False);
Expand All @@ -88,6 +90,8 @@ pub(crate) unsafe fn codegen(
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
if tcx.sess.default_hidden_visibility() {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
} else {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Protected);
}
let llval = llvm::LLVMConstInt(i8, 0, False);
llvm::LLVMSetInitializer(ll_g, llval);
Expand Down Expand Up @@ -134,6 +138,8 @@ fn create_wrapper_function(

if tcx.sess.default_hidden_visibility() {
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
} else {
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Protected);
}
if tcx.sess.must_emit_unwind_tables() {
let uwtable =
Expand Down
47 changes: 29 additions & 18 deletions compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,26 +902,37 @@ fn mono_item_visibility<'tcx>(
}

fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility {
if !tcx.sess.default_hidden_visibility() {
return Visibility::Default;
}
let export_level = if is_generic {
// Generic functions never have export-level C.
SymbolExportLevel::Rust
} else if !id.is_local() {
// Things with export level C don't get instantiated in
// downstream crates.
SymbolExportLevel::Rust
} else {
match tcx.reachable_non_generics(id.krate).get(&id) {
Some(SymbolExportInfo { level: SymbolExportLevel::C, .. }) => SymbolExportLevel::C,
_ => SymbolExportLevel::Rust,
}
};

// Generic functions never have export-level C.
if is_generic {
return Visibility::Hidden;
}
match export_level {
// C-export level items remain at `Default` to allow C code to
// access and interpose them.
SymbolExportLevel::C => Visibility::Default,

// Things with export level C don't get instantiated in
// downstream crates.
if !id.is_local() {
return Visibility::Hidden;
}

// C-export level items remain at `Default`, all other internal
// items become `Hidden`.
match tcx.reachable_non_generics(id.krate).get(&id) {
Some(SymbolExportInfo { level: SymbolExportLevel::C, .. }) => Visibility::Default,
_ => Visibility::Hidden,
// All other items become `Hidden` or `Protected` depending on
// `default_hidden_visibility`.
SymbolExportLevel::Rust => {
if tcx.sess.target.default_hidden_visibility {
Visibility::Hidden
} else {
// Items with mangled symbols don't have a predictable name,
// so no dylib that doesn't depend on compiler internals can
// do interposition on rust items.
Visibility::Protected
}
}
}
}

Expand Down

0 comments on commit 8303600

Please sign in to comment.