use crate::abi::{FnAbi, FnAbiLlvmExt};
use crate::attributes;
-use crate::llvm;
use crate::context::CodegenCx;
+use crate::llvm;
use crate::value::Value;
-use rustc_codegen_ssa::traits::*;
use log::debug;
+use rustc_codegen_ssa::traits::*;
-use rustc::ty::{TypeFoldable, Instance};
use rustc::ty::layout::{FnAbiExt, HasTyCtxt};
+use rustc::ty::{Instance, TypeFoldable};
/// Codegens a reference to a fn/method item, monomorphizing and
/// inlining as it goes.
///
/// - `cx`: the crate context
/// - `instance`: the instance to be instantiated
-pub fn get_fn(
- cx: &CodegenCx<'ll, 'tcx>,
- instance: Instance<'tcx>,
-) -> &'ll Value {
+pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value {
let tcx = cx.tcx();
debug!("get_fn(instance={:?})", instance);
}
let sym = tcx.symbol_name(instance).name.as_str();
- debug!("get_fn({:?}: {:?}) => {}", instance, instance.ty(cx.tcx()), sym);
+ debug!("get_fn({:?}: {:?}) => {}", instance, instance.monomorphic_ty(cx.tcx()), sym);
let fn_abi = FnAbi::of_instance(cx, instance, &[]);
// the current crate does not re-export generics, the
// definition of the instance will have been declared
// as `hidden`.
- if cx.tcx.is_unreachable_local_definition(instance_def_id) ||
- !cx.tcx.local_crate_exports_generics() {
+ if cx.tcx.is_unreachable_local_definition(instance_def_id)
+ || !cx.tcx.local_crate_exports_generics()
+ {
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
}
} else {
// This is a monomorphization of a generic function
// defined in an upstream crate.
- if cx.tcx.upstream_monomorphizations_for(instance_def_id)
- .map(|set| set.contains_key(instance.substs))
- .unwrap_or(false) {
+ if instance.upstream_monomorphization(tcx).is_some() {
// This is instantiated in another crate. It cannot
// be `hidden`.
} else {
}
}
- if cx.use_dll_storage_attrs &&
- tcx.is_dllimport_foreign_item(instance_def_id)
- {
+ if cx.use_dll_storage_attrs && tcx.is_dllimport_foreign_item(instance_def_id) {
unsafe {
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
}