Set dso_local for more items
This commit is contained in:
parent
46985d5d91
commit
f7ed4a799a
4 changed files with 72 additions and 1 deletions
|
@ -17,6 +17,7 @@ use rustc_middle::mir::mono::MonoItem;
|
|||
use rustc_middle::ty::{self, Instance, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_target::abi::{AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
|
||||
use rustc_target::spec::RelocModel;
|
||||
use tracing::debug;
|
||||
|
||||
pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll Value {
|
||||
|
@ -282,6 +283,12 @@ impl CodegenCx<'ll, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
if self.tcx.sess.relocation_model() == RelocModel::Static {
|
||||
unsafe {
|
||||
llvm::LLVMRustSetDSOLocal(g, true);
|
||||
}
|
||||
}
|
||||
|
||||
self.instances.borrow_mut().insert(instance, g);
|
||||
g
|
||||
}
|
||||
|
@ -363,6 +370,12 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
|
|||
set_global_alignment(&self, g, self.align_of(ty));
|
||||
llvm::LLVMSetInitializer(g, v);
|
||||
|
||||
let linkage = base::linkage_from_llvm(llvm::LLVMRustGetLinkage(g));
|
||||
let visibility = base::visibility_from_llvm(llvm::LLVMRustGetVisibility(g));
|
||||
if self.should_assume_dso_local(linkage, visibility) {
|
||||
llvm::LLVMRustSetDSOLocal(g, true);
|
||||
}
|
||||
|
||||
// As an optimization, all shared statics which do not have interior
|
||||
// mutability are placed into read-only memory.
|
||||
if !is_mutable && self.type_is_freeze(ty) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue