Skip to content

Commit

Permalink
Rename is_translated_fn query to is_translated_item and make it suppo…
Browse files Browse the repository at this point in the history
…rt statics.
  • Loading branch information
michaelwoerister committed Feb 19, 2018
1 parent 8ff633c commit 1be7f96
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/dep_node.rs
Expand Up @@ -625,7 +625,7 @@ define_dep_nodes!( <'tcx>
[eval_always] CollectAndPartitionTranslationItems,
[] ExportName(DefId),
[] ContainsExternIndicator(DefId),
[] IsTranslatedFunction(DefId),
[] IsTranslatedItem(DefId),
[] CodegenUnit(InternedString),
[] CompileCodegenUnit(InternedString),
[input] OutputFilenames,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/maps/mod.rs
Expand Up @@ -349,7 +349,7 @@ define_maps! { <'tcx>
[] fn export_name: ExportName(DefId) -> Option<Symbol>,
[] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
[] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
[] fn is_translated_function: IsTranslatedFunction(DefId) -> bool,
[] fn is_translated_item: IsTranslatedItem(DefId) -> bool,
[] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
[] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
[] fn output_filenames: output_filenames_node(CrateNum)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/maps/plumbing.rs
Expand Up @@ -929,7 +929,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::ContainsExternIndicator => {
force!(contains_extern_indicator, def_id!());
}
DepKind::IsTranslatedFunction => { force!(is_translated_function, def_id!()); }
DepKind::IsTranslatedItem => { force!(is_translated_item, def_id!()); }
DepKind::OutputFilenames => { force!(output_filenames, LOCAL_CRATE); }

DepKind::TargetFeaturesWhitelist => { force!(target_features_whitelist, LOCAL_CRATE); }
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_trans/base.rs
Expand Up @@ -1004,6 +1004,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
let translation_items: DefIdSet = items.iter().filter_map(|trans_item| {
match *trans_item {
MonoItem::Fn(ref instance) => Some(instance.def_id()),
MonoItem::Static(def_id) => Some(def_id),
_ => None,
}
}).collect();
Expand Down Expand Up @@ -1107,7 +1108,7 @@ impl CrateInfo {
}
}

fn is_translated_function(tcx: TyCtxt, id: DefId) -> bool {
fn is_translated_item(tcx: TyCtxt, id: DefId) -> bool {
let (all_trans_items, _) =
tcx.collect_and_partition_translation_items(LOCAL_CRATE);
all_trans_items.contains(&id)
Expand Down Expand Up @@ -1222,7 +1223,7 @@ pub fn provide(providers: &mut Providers) {
providers.collect_and_partition_translation_items =
collect_and_partition_translation_items;

providers.is_translated_function = is_translated_function;
providers.is_translated_item = is_translated_item;

providers.codegen_unit = |tcx, name| {
let (_, all) = tcx.collect_and_partition_translation_items(LOCAL_CRATE);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/callee.rs
Expand Up @@ -149,7 +149,7 @@ pub fn get_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
unsafe {
llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::ExternalLinkage);

if cx.tcx.is_translated_function(instance_def_id) {
if cx.tcx.is_translated_item(instance_def_id) {
if instance_def_id.is_local() {
if !cx.tcx.is_exported_symbol(instance_def_id) {
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
Expand Down

0 comments on commit 1be7f96

Please sign in to comment.