@@ -133,7 +133,7 @@ use symbol_map::SymbolMap;
133133use syntax:: ast:: NodeId ;
134134use syntax:: parse:: token:: { self , InternedString } ;
135135use trans_item:: TransItem ;
136- use util:: nodemap:: { FnvHashMap , FnvHashSet , NodeSet } ;
136+ use util:: nodemap:: { FnvHashMap , FnvHashSet } ;
137137
138138pub enum PartitioningStrategy {
139139 /// Generate one codegen unit per source-level module.
@@ -254,25 +254,17 @@ const FALLBACK_CODEGEN_UNIT: &'static str = "__rustc_fallback_codegen_unit";
254254pub fn partition < ' a , ' tcx , I > ( scx : & SharedCrateContext < ' a , ' tcx > ,
255255 trans_items : I ,
256256 strategy : PartitioningStrategy ,
257- inlining_map : & InliningMap < ' tcx > ,
258- reachable : & NodeSet )
257+ inlining_map : & InliningMap < ' tcx > )
259258 -> Vec < CodegenUnit < ' tcx > >
260259 where I : Iterator < Item = TransItem < ' tcx > >
261260{
262261 let tcx = scx. tcx ( ) ;
263262
264- if let PartitioningStrategy :: FixedUnitCount ( 1 ) = strategy {
265- // If there is only a single codegen-unit, we can use a very simple
266- // scheme and don't have to bother with doing much analysis.
267- return vec ! [ single_codegen_unit( tcx, trans_items, reachable) ] ;
268- }
269-
270263 // In the first step, we place all regular translation items into their
271264 // respective 'home' codegen unit. Regular translation items are all
272265 // functions and statics defined in the local crate.
273266 let mut initial_partitioning = place_root_translation_items ( scx,
274- trans_items,
275- reachable) ;
267+ trans_items) ;
276268
277269 debug_dump ( tcx, "INITIAL PARTITONING:" , initial_partitioning. codegen_units . iter ( ) ) ;
278270
@@ -310,8 +302,7 @@ struct PreInliningPartitioning<'tcx> {
310302struct PostInliningPartitioning < ' tcx > ( Vec < CodegenUnit < ' tcx > > ) ;
311303
312304fn place_root_translation_items < ' a , ' tcx , I > ( scx : & SharedCrateContext < ' a , ' tcx > ,
313- trans_items : I ,
314- _reachable : & NodeSet )
305+ trans_items : I )
315306 -> PreInliningPartitioning < ' tcx >
316307 where I : Iterator < Item = TransItem < ' tcx > >
317308{
@@ -320,7 +311,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
320311 let mut codegen_units = FnvHashMap ( ) ;
321312
322313 for trans_item in trans_items {
323- let is_root = !trans_item. is_instantiated_only_on_demand ( ) ;
314+ let is_root = !trans_item. is_instantiated_only_on_demand ( tcx ) ;
324315
325316 if is_root {
326317 let characteristic_def_id = characteristic_def_id_of_trans_item ( scx, trans_item) ;
@@ -350,6 +341,10 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
350341 // This is a non-generic functions, we always
351342 // make it visible externally on the chance that
352343 // it might be used in another codegen unit.
344+ // Later on base::internalize_symbols() will
345+ // assign "internal" linkage to those symbols
346+ // that are not referenced from other codegen
347+ // units (and are not publicly visible).
353348 llvm:: ExternalLinkage
354349 } else {
355350 // In the current setup, generic functions cannot
@@ -454,7 +449,6 @@ fn place_inlined_translation_items<'tcx>(initial_partitioning: PreInliningPartit
454449 // reliably in that case.
455450 new_codegen_unit. items . insert ( trans_item, llvm:: InternalLinkage ) ;
456451 } else {
457- assert ! ( trans_item. is_instantiated_only_on_demand( ) ) ;
458452 // We can't be sure if this will also be instantiated
459453 // somewhere else, so we add an instance here with
460454 // InternalLinkage so we don't get any conflicts.
@@ -550,68 +544,6 @@ fn compute_codegen_unit_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
550544 return token:: intern_and_get_ident ( & mod_path[ ..] ) ;
551545}
552546
553- fn single_codegen_unit < ' a , ' tcx , I > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
554- trans_items : I ,
555- reachable : & NodeSet )
556- -> CodegenUnit < ' tcx >
557- where I : Iterator < Item = TransItem < ' tcx > >
558- {
559- let mut items = FnvHashMap ( ) ;
560-
561- for trans_item in trans_items {
562- let linkage = trans_item. explicit_linkage ( tcx) . unwrap_or_else ( || {
563- match trans_item {
564- TransItem :: Static ( node_id) => {
565- if reachable. contains ( & node_id) {
566- llvm:: ExternalLinkage
567- } else {
568- llvm:: PrivateLinkage
569- }
570- }
571- TransItem :: DropGlue ( _) => {
572- llvm:: InternalLinkage
573- }
574- TransItem :: Fn ( instance) => {
575- if trans_item. is_generic_fn ( ) {
576- // FIXME(mw): Assigning internal linkage to all
577- // monomorphizations is potentially a waste of space
578- // since monomorphizations could be shared between
579- // crates. The main reason for making them internal is
580- // a limitation in MingW's binutils that cannot deal
581- // with COFF object that have more than 2^15 sections,
582- // which is something that can happen for large programs
583- // when every function gets put into its own COMDAT
584- // section.
585- llvm:: InternalLinkage
586- } else if trans_item. is_from_extern_crate ( ) {
587- // FIXME(mw): It would be nice if we could mark these as
588- // `AvailableExternallyLinkage`, since they should have
589- // been instantiated in the extern crate. But this
590- // sometimes leads to crashes on Windows because LLVM
591- // does not handle exception handling table instantiation
592- // reliably in that case.
593- llvm:: InternalLinkage
594- } else if reachable. contains ( & tcx. map
595- . as_local_node_id ( instance. def )
596- . unwrap ( ) ) {
597- llvm:: ExternalLinkage
598- } else {
599- // Functions that are not visible outside this crate can
600- // be marked as internal.
601- llvm:: InternalLinkage
602- }
603- }
604- }
605- } ) ;
606-
607- items. insert ( trans_item, linkage) ;
608- }
609-
610- CodegenUnit :: new (
611- numbered_codegen_unit_name ( & tcx. crate_name [ ..] , 0 ) ,
612- items)
613- }
614-
615547fn numbered_codegen_unit_name ( crate_name : & str , index : usize ) -> InternedString {
616548 token:: intern_and_get_ident ( & format ! ( "{}{}{}" ,
617549 crate_name,
0 commit comments