refactor: Remove LLVMRustInsertPrivateGlobal and define_private_global
Since it can easily be implemented using the existing LLVM C API in terms of `LLVMAddGlobal` and `LLVMSetLinkage` and `define_private_global` was only used in one place.
This commit is contained in:
@@ -240,11 +240,13 @@ impl<'ll> CodegenCx<'ll, '_> {
|
||||
let gv = self.define_global(&name, self.val_ty(cv)).unwrap_or_else(|| {
|
||||
bug!("symbol `{}` is already defined", name);
|
||||
});
|
||||
llvm::set_linkage(gv, llvm::Linkage::PrivateLinkage);
|
||||
gv
|
||||
}
|
||||
_ => self.define_private_global(self.val_ty(cv)),
|
||||
_ => self.define_global("", self.val_ty(cv)).unwrap_or_else(|| {
|
||||
bug!("anonymous global symbol is already defined");
|
||||
}),
|
||||
};
|
||||
llvm::set_linkage(gv, llvm::Linkage::PrivateLinkage);
|
||||
llvm::set_initializer(gv, cv);
|
||||
set_global_alignment(self, gv, align);
|
||||
llvm::set_unnamed_address(gv, llvm::UnnamedAddr::Global);
|
||||
|
||||
@@ -230,13 +230,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Declare a private global
|
||||
///
|
||||
/// Use this function when you intend to define a global without a name.
|
||||
pub(crate) fn define_private_global(&self, ty: &'ll Type) -> &'ll Value {
|
||||
unsafe { llvm::LLVMRustInsertPrivateGlobal(self.llmod(), ty) }
|
||||
}
|
||||
|
||||
/// Gets declared value by name.
|
||||
pub(crate) fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
|
||||
debug!("get_declared_value(name={:?})", name);
|
||||
|
||||
@@ -1954,7 +1954,6 @@ unsafe extern "C" {
|
||||
NameLen: size_t,
|
||||
T: &'a Type,
|
||||
) -> &'a Value;
|
||||
pub(crate) fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
|
||||
pub(crate) fn LLVMRustGetNamedValue(
|
||||
M: &Module,
|
||||
Name: *const c_char,
|
||||
|
||||
Reference in New Issue
Block a user