Skip to content

Commit

Permalink
rustc_codegen_ssa: remove define_fn and define_internal_fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Dec 3, 2019
1 parent 6a75768 commit db477af
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
22 changes: 0 additions & 22 deletions src/librustc_codegen_llvm/declare.rs
Expand Up @@ -130,28 +130,6 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
}

fn define_fn(
&self,
name: &str,
fn_sig: PolyFnSig<'tcx>,
) -> &'ll Value {
if self.get_defined_value(name).is_some() {
self.sess().fatal(&format!("symbol `{}` already defined", name))
} else {
self.declare_fn(name, fn_sig)
}
}

fn define_internal_fn(
&self,
name: &str,
fn_sig: PolyFnSig<'tcx>,
) -> &'ll Value {
let llfn = self.define_fn(name, fn_sig);
unsafe { llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::InternalLinkage) };
llfn
}

fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
debug!("get_declared_value(name={:?})", name);
let namebuf = SmallCStr::new(name);
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Expand Up @@ -1013,7 +1013,9 @@ fn gen_fn<'ll, 'tcx>(
hir::Unsafety::Unsafe,
Abi::Rust
));
let llfn = cx.define_internal_fn(name, rust_fn_sig);
let llfn = cx.declare_fn(name, rust_fn_sig);
// FIXME(eddyb) find a nicer way to do this.
unsafe { llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::InternalLinkage) };
attributes::from_fn_attrs(cx, llfn, None, rust_fn_sig);
let bx = Builder::new_block(cx, llfn, "entry-block");
codegen(bx);
Expand Down
14 changes: 0 additions & 14 deletions src/librustc_codegen_ssa/traits/declare.rs
Expand Up @@ -38,20 +38,6 @@ pub trait DeclareMethods<'tcx>: BackendTypes {
/// Use this function when you intend to define a global without a name.
fn define_private_global(&self, ty: Self::Type) -> Self::Value;

/// Declare a Rust function with an intention to define it.
///
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
fn define_fn(&self, name: &str, fn_sig: ty::PolyFnSig<'tcx>) -> Self::Value;

/// Declare a Rust function with an intention to define it.
///
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
fn define_internal_fn(&self, name: &str, fn_sig: ty::PolyFnSig<'tcx>) -> Self::Value;

/// Gets declared value by name.
fn get_declared_value(&self, name: &str) -> Option<Self::Value>;

Expand Down

0 comments on commit db477af

Please sign in to comment.