From 197cc1e43afba388a0266a08d2b946a187b766bb Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 22 Jan 2020 12:17:21 +0100 Subject: Add projection query for upstream drop-glue instances. This reduces the amount of invalidated data when new types are add to upstream crates. --- src/librustc_codegen_utils/symbol_names.rs | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/librustc_codegen_utils') diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 96a74f96fcf..6713459f627 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -126,29 +126,10 @@ fn symbol_name_provider(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::Symb // This closure determines the instantiating crate for instances that // need an instantiating-crate-suffix for their symbol name, in order // to differentiate between local copies. - // - // For generics we might find re-usable upstream instances. For anything - // else we rely on their being a local copy available. - if is_generic(instance.substs) { - let def_id = instance.def_id(); - - if !def_id.is_local() && tcx.sess.opts.share_generics() { - // If we are re-using a monomorphization from another crate, - // we have to compute the symbol hash accordingly. - let upstream_monomorphizations = tcx.upstream_monomorphizations_for(def_id); - - upstream_monomorphizations - .and_then(|monos| monos.get(&instance.substs).cloned()) - // If there is no instance available upstream, there'll be - // one in the current crate. - .unwrap_or(LOCAL_CRATE) - } else { - // For generic functions defined in the current crate, there - // can be no upstream instances. Also, if we don't share - // generics, we'll instantiate a local copy too. - LOCAL_CRATE - } + // For generics we might find re-usable upstream instances. If there + // is one, we rely on the symbol being instantiated locally. + instance.upstream_monomorphization(tcx).unwrap_or(LOCAL_CRATE) } else { // For non-generic things that need to avoid naming conflicts, we // always instantiate a copy in the local crate. -- cgit 1.4.1-3-g733a5