about summary refs log tree commit diff
path: root/src/librustc_codegen_utils
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2020-01-22 12:17:21 +0100
committerMichael Woerister <michaelwoerister@posteo>2020-01-23 16:56:59 +0100
commit197cc1e43afba388a0266a08d2b946a187b766bb (patch)
tree74a4b064655c776105752655c23056ab580683e8 /src/librustc_codegen_utils
parent2ceb92bc53a849e36341c3fd619cb49470e224e2 (diff)
Add projection query for upstream drop-glue instances.
This reduces the amount of invalidated data when new types are
add to upstream crates.
Diffstat (limited to 'src/librustc_codegen_utils')
-rw-r--r--src/librustc_codegen_utils/symbol_names.rs25
1 files changed, 3 insertions, 22 deletions
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.