Make drop-glue take advantage of -Zshare-generics.
This commit is contained in:
parent
190f0c0b0b
commit
2ceb92bc53
5 changed files with 52 additions and 16 deletions
|
|
@ -5,7 +5,7 @@ use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
|||
use rustc::middle::exported_symbols::{metadata_symbol_name, ExportedSymbol, SymbolExportLevel};
|
||||
use rustc::session::config::{self, Sanitizer};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::subst::SubstsRef;
|
||||
use rustc::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc::ty::Instance;
|
||||
use rustc::ty::{SymbolName, TyCtxt};
|
||||
use rustc_codegen_utils::symbol_names;
|
||||
|
|
@ -248,19 +248,31 @@ fn exported_symbols_provider_local(
|
|||
continue;
|
||||
}
|
||||
|
||||
if let &MonoItem::Fn(Instance { def: InstanceDef::Item(def_id), substs }) = mono_item {
|
||||
if substs.non_erasable_generics().next().is_some() {
|
||||
symbols
|
||||
.push((ExportedSymbol::Generic(def_id, substs), SymbolExportLevel::Rust));
|
||||
match *mono_item {
|
||||
MonoItem::Fn(Instance { def: InstanceDef::Item(def_id), substs }) => {
|
||||
if substs.non_erasable_generics().next().is_some() {
|
||||
let symbol = ExportedSymbol::Generic(def_id, substs);
|
||||
symbols.push((symbol, SymbolExportLevel::Rust));
|
||||
}
|
||||
}
|
||||
MonoItem::Fn(Instance { def: InstanceDef::DropGlue(def_id, Some(ty)), substs }) => {
|
||||
// A little sanity-check
|
||||
debug_assert_eq!(
|
||||
substs.non_erasable_generics().next(),
|
||||
Some(GenericArgKind::Type(ty))
|
||||
);
|
||||
let symbol = ExportedSymbol::Generic(def_id, substs);
|
||||
symbols.push((symbol, SymbolExportLevel::Rust));
|
||||
}
|
||||
_ => {
|
||||
// Any other symbols don't qualify for sharing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort so we get a stable incr. comp. hash.
|
||||
symbols.sort_unstable_by(|&(ref symbol1, ..), &(ref symbol2, ..)| {
|
||||
symbol1.compare_stable(tcx, symbol2)
|
||||
});
|
||||
symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx));
|
||||
|
||||
Arc::new(symbols)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue