From 6bc7f41955c7583eca76c77fb45e51e3431cc89e Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Mon, 26 Feb 2018 20:14:58 -0500 Subject: [PATCH] Remove the contains_extern_indicator query Part of #47320 --- src/librustc/dep_graph/dep_node.rs | 1 - src/librustc/hir/mod.rs | 6 ++++++ src/librustc/middle/reachable.rs | 2 +- src/librustc/ty/maps/config.rs | 1 - src/librustc/ty/maps/mod.rs | 1 - src/librustc/ty/maps/on_disk_cache.rs | 1 - src/librustc/ty/maps/plumbing.rs | 4 ---- src/librustc_trans/back/symbol_export.rs | 3 ++- src/librustc_trans_utils/symbol_names.rs | 5 ----- src/librustc_trans_utils/trans_crate.rs | 1 - src/librustc_typeck/collect.rs | 2 ++ 11 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index d50776b606247..2550ef667e080 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -627,7 +627,6 @@ define_dep_nodes!( <'tcx> [input] AllCrateNums, [] ExportedSymbols(CrateNum), [eval_always] CollectAndPartitionTranslationItems, - [] ContainsExternIndicator(DefId), [] IsTranslatedItem(DefId), [] CodegenUnit(InternedString), [] CompileCodegenUnit(InternedString), diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index c2fbf4df48911..e9bada5a1478d 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2227,6 +2227,7 @@ bitflags! { const UNWIND = 0b0000_0100; const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000; const NAKED = 0b0001_0000; + const NO_MANGLE = 0b0010_0000; } } @@ -2246,5 +2247,10 @@ impl TransFnAttrs { InlineAttr::None | InlineAttr::Never => false, } } + + /// True if `#[no_mangle]` or `#[export_name(...)]` is present. + pub fn contains_extern_indicator(&self) -> bool { + self.flags.contains(TransFnAttrFlags::NO_MANGLE) || self.export_name.is_some() + } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index dd581278607ee..48a62c8c14d69 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -233,7 +233,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { false }; let def_id = self.tcx.hir.local_def_id(item.id); - let is_extern = self.tcx.contains_extern_indicator(def_id); + let is_extern = self.tcx.trans_fn_attrs(def_id).contains_extern_indicator(); if reachable || is_extern { self.reachable_symbols.insert(search_item); } diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index cfc552bdc85c5..fdc929ed08413 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -687,7 +687,6 @@ impl_disk_cacheable_query!(borrowck, |def_id| def_id.is_local()); impl_disk_cacheable_query!(mir_borrowck, |def_id| def_id.is_local()); impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local()); impl_disk_cacheable_query!(check_match, |def_id| def_id.is_local()); -impl_disk_cacheable_query!(contains_extern_indicator, |_| true); impl_disk_cacheable_query!(def_symbol_name, |_| true); impl_disk_cacheable_query!(type_of, |def_id| def_id.is_local()); impl_disk_cacheable_query!(predicates_of, |def_id| def_id.is_local()); diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 3a8dddaec114a..9fb021ea6d767 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -363,7 +363,6 @@ define_maps! { <'tcx> [] fn collect_and_partition_translation_items: collect_and_partition_translation_items_node(CrateNum) -> (Arc, Arc>>>), - [] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool, [] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel, [] fn is_translated_item: IsTranslatedItem(DefId) -> bool, [] fn codegen_unit: CodegenUnit(InternedString) -> Arc>, diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 65f2d476475e9..ba99c80ffeba5 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -217,7 +217,6 @@ impl<'sess> OnDiskCache<'sess> { encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; } diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 3c70257be71b6..69332f6502f7e 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -926,9 +926,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::CollectAndPartitionTranslationItems => { force!(collect_and_partition_translation_items, LOCAL_CRATE); } - DepKind::ContainsExternIndicator => { - force!(contains_extern_indicator, def_id!()); - } DepKind::IsTranslatedItem => { force!(is_translated_item, def_id!()); } DepKind::OutputFilenames => { force!(output_filenames, LOCAL_CRATE); } @@ -997,7 +994,6 @@ impl_load_from_cache!( MirConstQualif => mir_const_qualif, SymbolName => def_symbol_name, ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static, - ContainsExternIndicator => contains_extern_indicator, CheckMatch => check_match, TypeOfItem => type_of, GenericsOfItem => generics_of, diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 739ae768ca29c..799d8319767aa 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -256,7 +256,8 @@ fn symbol_export_level_provider(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportL // special symbols in the standard library for various plumbing between // core/std/allocators/etc. For example symbols used to hook up allocation // are not considered for export - let is_extern = tcx.contains_extern_indicator(sym_def_id); + let trans_fn_attrs = tcx.trans_fn_attrs(sym_def_id); + let is_extern = trans_fn_attrs.contains_extern_indicator(); let std_internal = attr::contains_name(&tcx.get_attrs(sym_def_id), "rustc_std_internal_symbol"); if is_extern && !std_internal { diff --git a/src/librustc_trans_utils/symbol_names.rs b/src/librustc_trans_utils/symbol_names.rs index 6c96620f7b65c..f9f93730255e6 100644 --- a/src/librustc_trans_utils/symbol_names.rs +++ b/src/librustc_trans_utils/symbol_names.rs @@ -120,11 +120,6 @@ pub fn provide(providers: &mut Providers) { def_symbol_name, symbol_name, - contains_extern_indicator: |tcx, id| { - attr::contains_name(&tcx.get_attrs(id), "no_mangle") || - tcx.trans_fn_attrs(id).export_name.is_some() - }, - ..*providers }; } diff --git a/src/librustc_trans_utils/trans_crate.rs b/src/librustc_trans_utils/trans_crate.rs index 175729ad19f4c..04e993f1b0321 100644 --- a/src/librustc_trans_utils/trans_crate.rs +++ b/src/librustc_trans_utils/trans_crate.rs @@ -233,7 +233,6 @@ impl TransCrate for MetadataOnlyTransCrate { MonoItem::Fn(inst) => { let def_id = inst.def_id(); if def_id.is_local() { - let _ = tcx.contains_extern_indicator(def_id); let _ = inst.def.is_inline(tcx); let _ = tcx.trans_fn_attrs(def_id); } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 55d77ee27fece..76d2be6695c75 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1743,6 +1743,8 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt trans_fn_attrs.flags |= TransFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND; } else if attr.check_name("naked") { trans_fn_attrs.flags |= TransFnAttrFlags::NAKED; + } else if attr.check_name("no_mangle") { + trans_fn_attrs.flags |= TransFnAttrFlags::NO_MANGLE; } else if attr.check_name("inline") { trans_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| { if attr.path != "inline" {