Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move collector to rustc_trans_utils #45381

Merged
merged 1 commit into from
Oct 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/librustc_trans/back/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
//! DefPaths which are much more robust in the face of changes to the code base.
use monomorphize::Instance;
use trans_item::{TransItemExt, InstantiationMode};
use trans_item::{BaseTransItemExt, InstantiationMode};

use rustc::middle::weak_lang_items;
use rustc::middle::trans::TransItem;
Expand Down
30 changes: 2 additions & 28 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use monomorphize::{self, Instance};
use partitioning::{self, PartitioningStrategy, CodegenUnit, CodegenUnitExt};
use symbol_names_test;
use time_graph;
use trans_item::{TransItem, TransItemExt, DefPathBasedNames};
use trans_item::{TransItem, BaseTransItemExt, TransItemExt, DefPathBasedNames};
use type_::Type;
use type_of;
use value::Value;
Expand All @@ -93,6 +93,7 @@ use syntax::ast;
use mir::lvalue::Alignment;

pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr};
pub use rustc_trans_utils::trans_item::linkage_by_name;

pub struct StatRecorder<'a, 'tcx: 'a> {
ccx: &'a CrateContext<'a, 'tcx>,
Expand Down Expand Up @@ -618,33 +619,6 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
mir::trans_mir(ccx, lldecl, &mir, instance, sig);
}

pub fn linkage_by_name(name: &str) -> Option<Linkage> {
use rustc::middle::trans::Linkage::*;

// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
// applicable to variable declarations and may not really make sense for
// Rust code in the first place but whitelist them anyway and trust that
// the user knows what s/he's doing. Who knows, unanticipated use cases
// may pop up in the future.
//
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
// and don't have to be, LLVM treats them as no-ops.
match name {
"appending" => Some(Appending),
"available_externally" => Some(AvailableExternally),
"common" => Some(Common),
"extern_weak" => Some(ExternalWeak),
"external" => Some(External),
"internal" => Some(Internal),
"linkonce" => Some(LinkOnceAny),
"linkonce_odr" => Some(LinkOnceODR),
"private" => Some(Private),
"weak" => Some(WeakAny),
"weak_odr" => Some(WeakODR),
_ => None,
}
}

pub fn set_link_section(ccx: &CrateContext,
llval: ValueRef,
attrs: &[ast::Attribute]) {
Expand Down
17 changes: 0 additions & 17 deletions src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use libc::{c_uint, c_char};
use std::iter;

use syntax::abi::Abi;
use syntax::attr;
use syntax::symbol::InternedString;
use syntax_pos::{Span, DUMMY_SP};

Expand Down Expand Up @@ -552,22 +551,6 @@ pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}

pub fn requests_inline<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
instance: &ty::Instance<'tcx>
) -> bool {
if is_inline_instance(tcx, instance) {
return true
}
if let ty::InstanceDef::DropGlue(..) = instance.def {
// Drop glue wants to be instantiated at every translation
// unit, but without an #[inline] hint. We should make this
// available to normal end-users.
return true
}
attr::requests_inline(&instance.def.attrs(tcx)[..])
}

pub fn is_inline_instance<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
instance: &ty::Instance<'tcx>
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ use rustc::ty::maps::Providers;
use rustc::ty::{self, TyCtxt};
use rustc::util::nodemap::{FxHashSet, FxHashMap};

use rustc_trans_utils::collector;
use rustc_trans_utils::monomorphize;

mod diagnostics;

pub mod back {
Expand Down Expand Up @@ -124,7 +127,6 @@ mod cabi_x86;
mod cabi_x86_64;
mod cabi_x86_win64;
mod callee;
mod collector;
mod common;
mod consts;
mod context;
Expand All @@ -137,7 +139,6 @@ mod machine;
mod metadata;
mod meth;
mod mir;
mod monomorphize;
mod partitioning;
mod symbol_names_test;
mod time_graph;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet};
use std::collections::hash_map::Entry;
use syntax::ast::NodeId;
use syntax::symbol::{Symbol, InternedString};
use trans_item::{TransItem, TransItemExt, InstantiationMode};
use trans_item::{TransItem, BaseTransItemExt, TransItemExt, InstantiationMode};

pub use rustc::middle::trans::CodegenUnit;

Expand Down
Loading