Skip to content

Commit 7f06055

Browse files
committed
Auto merge of #45381 - bjorn3:move_collector_out_of_trans, r=nikomatsakis
Move collector to rustc_trans_utils
2 parents cc03782 + 906523e commit 7f06055

File tree

13 files changed

+565
-460
lines changed

13 files changed

+565
-460
lines changed

src/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_trans/back/symbol_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
//! DefPaths which are much more robust in the face of changes to the code base.
9999
100100
use monomorphize::Instance;
101-
use trans_item::{TransItemExt, InstantiationMode};
101+
use trans_item::{BaseTransItemExt, InstantiationMode};
102102

103103
use rustc::middle::weak_lang_items;
104104
use rustc::middle::trans::TransItem;

src/librustc_trans/base.rs

+2-28
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use monomorphize::{self, Instance};
7070
use partitioning::{self, PartitioningStrategy, CodegenUnit, CodegenUnitExt};
7171
use symbol_names_test;
7272
use time_graph;
73-
use trans_item::{TransItem, TransItemExt, DefPathBasedNames};
73+
use trans_item::{TransItem, BaseTransItemExt, TransItemExt, DefPathBasedNames};
7474
use type_::Type;
7575
use type_of;
7676
use value::Value;
@@ -93,6 +93,7 @@ use syntax::ast;
9393
use mir::lvalue::Alignment;
9494

9595
pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr};
96+
pub use rustc_trans_utils::trans_item::linkage_by_name;
9697

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

621-
pub fn linkage_by_name(name: &str) -> Option<Linkage> {
622-
use rustc::middle::trans::Linkage::*;
623-
624-
// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
625-
// applicable to variable declarations and may not really make sense for
626-
// Rust code in the first place but whitelist them anyway and trust that
627-
// the user knows what s/he's doing. Who knows, unanticipated use cases
628-
// may pop up in the future.
629-
//
630-
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
631-
// and don't have to be, LLVM treats them as no-ops.
632-
match name {
633-
"appending" => Some(Appending),
634-
"available_externally" => Some(AvailableExternally),
635-
"common" => Some(Common),
636-
"extern_weak" => Some(ExternalWeak),
637-
"external" => Some(External),
638-
"internal" => Some(Internal),
639-
"linkonce" => Some(LinkOnceAny),
640-
"linkonce_odr" => Some(LinkOnceODR),
641-
"private" => Some(Private),
642-
"weak" => Some(WeakAny),
643-
"weak_odr" => Some(WeakODR),
644-
_ => None,
645-
}
646-
}
647-
648622
pub fn set_link_section(ccx: &CrateContext,
649623
llval: ValueRef,
650624
attrs: &[ast::Attribute]) {

src/librustc_trans/common.rs

-17
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use libc::{c_uint, c_char};
3636
use std::iter;
3737

3838
use syntax::abi::Abi;
39-
use syntax::attr;
4039
use syntax::symbol::InternedString;
4140
use syntax_pos::{Span, DUMMY_SP};
4241

@@ -552,22 +551,6 @@ pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
552551
}
553552
}
554553

555-
pub fn requests_inline<'a, 'tcx>(
556-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
557-
instance: &ty::Instance<'tcx>
558-
) -> bool {
559-
if is_inline_instance(tcx, instance) {
560-
return true
561-
}
562-
if let ty::InstanceDef::DropGlue(..) = instance.def {
563-
// Drop glue wants to be instantiated at every translation
564-
// unit, but without an #[inline] hint. We should make this
565-
// available to normal end-users.
566-
return true
567-
}
568-
attr::requests_inline(&instance.def.attrs(tcx)[..])
569-
}
570-
571554
pub fn is_inline_instance<'a, 'tcx>(
572555
tcx: TyCtxt<'a, 'tcx, 'tcx>,
573556
instance: &ty::Instance<'tcx>

src/librustc_trans/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ use rustc::ty::maps::Providers;
8383
use rustc::ty::{self, TyCtxt};
8484
use rustc::util::nodemap::{FxHashSet, FxHashMap};
8585

86+
use rustc_trans_utils::collector;
87+
use rustc_trans_utils::monomorphize;
88+
8689
mod diagnostics;
8790

8891
pub mod back {
@@ -124,7 +127,6 @@ mod cabi_x86;
124127
mod cabi_x86_64;
125128
mod cabi_x86_win64;
126129
mod callee;
127-
mod collector;
128130
mod common;
129131
mod consts;
130132
mod context;
@@ -137,7 +139,6 @@ mod machine;
137139
mod metadata;
138140
mod meth;
139141
mod mir;
140-
mod monomorphize;
141142
mod partitioning;
142143
mod symbol_names_test;
143144
mod time_graph;

src/librustc_trans/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet};
114114
use std::collections::hash_map::Entry;
115115
use syntax::ast::NodeId;
116116
use syntax::symbol::{Symbol, InternedString};
117-
use trans_item::{TransItem, TransItemExt, InstantiationMode};
117+
use trans_item::{TransItem, BaseTransItemExt, TransItemExt, InstantiationMode};
118118

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

0 commit comments

Comments
 (0)