X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_codegen_llvm%2Fcallee.rs;h=78dd6fc8ffe750d80f504b366a6a6b0922576606;hb=d493dccef7ae1d2ca739fe828bf9556b44dc460a;hp=c0be87b117d65d063d0941f7868f517299685e11;hpb=1c12dc8cdf36b62e93ce74cecc15f13e57f281d3;p=rust.git diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index c0be87b117d..78dd6fc8ffe 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -6,14 +6,14 @@ 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. @@ -22,10 +22,7 @@ /// /// - `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); @@ -39,7 +36,7 @@ pub fn get_fn( } 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, &[]); @@ -125,16 +122,20 @@ pub fn get_fn( // 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 cx + .tcx + .upstream_monomorphizations_for(instance_def_id) + .map(|set| set.contains_key(instance.substs)) + .unwrap_or(false) + { // This is instantiated in another crate. It cannot // be `hidden`. } else { @@ -172,9 +173,7 @@ pub fn get_fn( } } - 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); }