Don't export global allocs which are not statics
They aren't be referenced outside of the current cgu anyway. This should make optimizations a bit more effective.
This commit is contained in:
parent
710b7415cd
commit
beb1767842
@ -170,11 +170,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||||||
match kind {
|
match kind {
|
||||||
Some(kind) if !self.tcx.sess.fewer_names() => {
|
Some(kind) if !self.tcx.sess.fewer_names() => {
|
||||||
let name = self.generate_local_symbol_name(kind);
|
let name = self.generate_local_symbol_name(kind);
|
||||||
// TODO(antoyo): check if it's okay that TLS is off here.
|
// TODO(antoyo): check if it's okay that no link_section is set.
|
||||||
// TODO(antoyo): check if it's okay that link_section is None here.
|
|
||||||
// TODO(antoyo): set alignment here as well.
|
// TODO(antoyo): set alignment here as well.
|
||||||
let global = self.define_global(&name[..], self.val_ty(cv), false, None);
|
let global = self.declare_private_global(&name[..], self.val_ty(cv));
|
||||||
// TODO(antoyo): set linkage.
|
|
||||||
global
|
global
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -183,8 +181,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||||||
global
|
global
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// FIXME(antoyo): I think the name coming from generate_local_symbol_name() above cannot be used
|
|
||||||
// globally.
|
|
||||||
global.global_set_initializer_rvalue(cv);
|
global.global_set_initializer_rvalue(cv);
|
||||||
// TODO(antoyo): set unnamed address.
|
// TODO(antoyo): set unnamed address.
|
||||||
let rvalue = global.get_address(None);
|
let rvalue = global.get_address(None);
|
||||||
|
@ -18,7 +18,6 @@ use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDat
|
|||||||
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
|
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
|
||||||
|
|
||||||
use crate::callee::get_fn;
|
use crate::callee::get_fn;
|
||||||
use crate::declare::mangle_name;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FuncSig<'gcc> {
|
pub struct FuncSig<'gcc> {
|
||||||
@ -96,7 +95,6 @@ pub struct CodegenCx<'gcc, 'tcx> {
|
|||||||
|
|
||||||
/// A counter that is used for generating local symbol names
|
/// A counter that is used for generating local symbol names
|
||||||
local_gen_sym_counter: Cell<usize>,
|
local_gen_sym_counter: Cell<usize>,
|
||||||
pub global_gen_sym_counter: Cell<usize>,
|
|
||||||
|
|
||||||
eh_personality: Cell<Option<RValue<'gcc>>>,
|
eh_personality: Cell<Option<RValue<'gcc>>>,
|
||||||
|
|
||||||
@ -221,7 +219,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||||||
struct_types: Default::default(),
|
struct_types: Default::default(),
|
||||||
types_with_fields_to_set: Default::default(),
|
types_with_fields_to_set: Default::default(),
|
||||||
local_gen_sym_counter: Cell::new(0),
|
local_gen_sym_counter: Cell::new(0),
|
||||||
global_gen_sym_counter: Cell::new(0),
|
|
||||||
eh_personality: Cell::new(None),
|
eh_personality: Cell::new(None),
|
||||||
pointee_infos: Default::default(),
|
pointee_infos: Default::default(),
|
||||||
structs_as_pointer: Default::default(),
|
structs_as_pointer: Default::default(),
|
||||||
@ -503,11 +500,6 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unit_name<'tcx>(codegen_unit: &CodegenUnit<'tcx>) -> String {
|
|
||||||
let name = &codegen_unit.name().to_string();
|
|
||||||
mangle_name(&name.replace('-', "_"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_gcc_tls_mode(tls_model: TlsModel) -> gccjit::TlsModel {
|
fn to_gcc_tls_mode(tls_model: TlsModel) -> gccjit::TlsModel {
|
||||||
match tls_model {
|
match tls_model {
|
||||||
TlsModel::GeneralDynamic => gccjit::TlsModel::GlobalDynamic,
|
TlsModel::GeneralDynamic => gccjit::TlsModel::GlobalDynamic,
|
||||||
|
@ -5,7 +5,7 @@ use rustc_span::Symbol;
|
|||||||
use rustc_target::abi::call::FnAbi;
|
use rustc_target::abi::call::FnAbi;
|
||||||
|
|
||||||
use crate::abi::FnAbiGccExt;
|
use crate::abi::FnAbiGccExt;
|
||||||
use crate::context::{CodegenCx, unit_name};
|
use crate::context::CodegenCx;
|
||||||
use crate::intrinsic::llvm;
|
use crate::intrinsic::llvm;
|
||||||
|
|
||||||
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||||
@ -27,10 +27,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn declare_unnamed_global(&self, ty: Type<'gcc>) -> LValue<'gcc> {
|
pub fn declare_unnamed_global(&self, ty: Type<'gcc>) -> LValue<'gcc> {
|
||||||
let index = self.global_gen_sym_counter.get();
|
let name = self.generate_local_symbol_name("global");
|
||||||
self.global_gen_sym_counter.set(index + 1);
|
self.context.new_global(None, GlobalKind::Internal, ty, &name)
|
||||||
let name = format!("global_{}_{}", index, unit_name(&self.codegen_unit));
|
|
||||||
self.context.new_global(None, GlobalKind::Exported, ty, &name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn declare_global_with_linkage(&self, name: &str, ty: Type<'gcc>, linkage: GlobalKind) -> LValue<'gcc> {
|
pub fn declare_global_with_linkage(&self, name: &str, ty: Type<'gcc>, linkage: GlobalKind) -> LValue<'gcc> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user