Skip to content

Commit

Permalink
Remove the contains_extern_indicator query
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Mar 7, 2018
1 parent 5460b88 commit 6bc7f41
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ define_dep_nodes!( <'tcx>
[input] AllCrateNums,
[] ExportedSymbols(CrateNum),
[eval_always] CollectAndPartitionTranslationItems,
[] ContainsExternIndicator(DefId),
[] IsTranslatedItem(DefId),
[] CodegenUnit(InternedString),
[] CompileCodegenUnit(InternedString),
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,7 @@ bitflags! {
const UNWIND = 0b0000_0100;
const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000;
const NAKED = 0b0001_0000;
const NO_MANGLE = 0b0010_0000;
}
}

Expand All @@ -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()
}
}

2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/maps/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ define_maps! { <'tcx>
[] fn collect_and_partition_translation_items:
collect_and_partition_translation_items_node(CrateNum)
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
[] 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<CodegenUnit<'tcx>>,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/maps/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ impl<'sess> OnDiskCache<'sess> {
encode_query_results::<mir_const_qualif, _>(tcx, enc, qri)?;
encode_query_results::<def_symbol_name, _>(tcx, enc, qri)?;
encode_query_results::<const_is_rvalue_promotable_to_static, _>(tcx, enc, qri)?;
encode_query_results::<contains_extern_indicator, _>(tcx, enc, qri)?;
encode_query_results::<symbol_name, _>(tcx, enc, qri)?;
encode_query_results::<check_match, _>(tcx, enc, qri)?;
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/ty/maps/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions src/librustc_trans_utils/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_trans_utils/trans_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 6bc7f41

Please sign in to comment.