@@ -54,7 +54,6 @@ use attributes;
54
54
use builder:: { Builder , MemFlags } ;
55
55
use callee;
56
56
use common:: { C_bool , C_bytes_in_context , C_i32 , C_usize } ;
57
- use rustc_mir:: monomorphize:: collector:: { self , MonoItemCollectionMode } ;
58
57
use rustc_mir:: monomorphize:: item:: DefPathBasedNames ;
59
58
use common:: { C_struct_in_context , C_array , val_ty} ;
60
59
use consts;
@@ -64,13 +63,13 @@ use declare;
64
63
use meth;
65
64
use mir;
66
65
use monomorphize:: Instance ;
67
- use monomorphize:: partitioning:: { self , PartitioningStrategy , CodegenUnit , CodegenUnitExt } ;
66
+ use monomorphize:: partitioning:: { CodegenUnit , CodegenUnitExt } ;
68
67
use rustc_codegen_utils:: symbol_names_test;
69
68
use time_graph;
70
- use mono_item:: { MonoItem , BaseMonoItemExt , MonoItemExt } ;
69
+ use mono_item:: { MonoItem , MonoItemExt } ;
71
70
use type_:: Type ;
72
71
use type_of:: LayoutLlvmExt ;
73
- use rustc:: util:: nodemap:: { FxHashMap , DefIdSet } ;
72
+ use rustc:: util:: nodemap:: FxHashMap ;
74
73
use CrateInfo ;
75
74
use rustc_data_structures:: small_c_str:: SmallCStr ;
76
75
use rustc_data_structures:: sync:: Lrc ;
@@ -80,7 +79,6 @@ use std::cmp;
80
79
use std:: ffi:: CString ;
81
80
use std:: i32;
82
81
use std:: ops:: { Deref , DerefMut } ;
83
- use std:: sync:: Arc ;
84
82
use std:: sync:: mpsc;
85
83
use std:: time:: { Instant , Duration } ;
86
84
use syntax_pos:: Span ;
@@ -1011,128 +1009,6 @@ fn assert_and_save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
1011
1009
|| rustc_incremental:: save_dep_graph ( tcx) ) ;
1012
1010
}
1013
1011
1014
- fn collect_and_partition_mono_items < ' a , ' tcx > (
1015
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1016
- cnum : CrateNum ,
1017
- ) -> ( Arc < DefIdSet > , Arc < Vec < Arc < CodegenUnit < ' tcx > > > > )
1018
- {
1019
- assert_eq ! ( cnum, LOCAL_CRATE ) ;
1020
-
1021
- let collection_mode = match tcx. sess . opts . debugging_opts . print_mono_items {
1022
- Some ( ref s) => {
1023
- let mode_string = s. to_lowercase ( ) ;
1024
- let mode_string = mode_string. trim ( ) ;
1025
- if mode_string == "eager" {
1026
- MonoItemCollectionMode :: Eager
1027
- } else {
1028
- if mode_string != "lazy" {
1029
- let message = format ! ( "Unknown codegen-item collection mode '{}'. \
1030
- Falling back to 'lazy' mode.",
1031
- mode_string) ;
1032
- tcx. sess . warn ( & message) ;
1033
- }
1034
-
1035
- MonoItemCollectionMode :: Lazy
1036
- }
1037
- }
1038
- None => {
1039
- if tcx. sess . opts . cg . link_dead_code {
1040
- MonoItemCollectionMode :: Eager
1041
- } else {
1042
- MonoItemCollectionMode :: Lazy
1043
- }
1044
- }
1045
- } ;
1046
-
1047
- let ( items, inlining_map) =
1048
- time ( tcx. sess , "monomorphization collection" , || {
1049
- collector:: collect_crate_mono_items ( tcx, collection_mode)
1050
- } ) ;
1051
-
1052
- tcx. sess . abort_if_errors ( ) ;
1053
-
1054
- :: rustc_mir:: monomorphize:: assert_symbols_are_distinct ( tcx, items. iter ( ) ) ;
1055
-
1056
- let strategy = if tcx. sess . opts . incremental . is_some ( ) {
1057
- PartitioningStrategy :: PerModule
1058
- } else {
1059
- PartitioningStrategy :: FixedUnitCount ( tcx. sess . codegen_units ( ) )
1060
- } ;
1061
-
1062
- let codegen_units = time ( tcx. sess , "codegen unit partitioning" , || {
1063
- partitioning:: partition ( tcx,
1064
- items. iter ( ) . cloned ( ) ,
1065
- strategy,
1066
- & inlining_map)
1067
- . into_iter ( )
1068
- . map ( Arc :: new)
1069
- . collect :: < Vec < _ > > ( )
1070
- } ) ;
1071
-
1072
- let mono_items: DefIdSet = items. iter ( ) . filter_map ( |mono_item| {
1073
- match * mono_item {
1074
- MonoItem :: Fn ( ref instance) => Some ( instance. def_id ( ) ) ,
1075
- MonoItem :: Static ( def_id) => Some ( def_id) ,
1076
- _ => None ,
1077
- }
1078
- } ) . collect ( ) ;
1079
-
1080
- if tcx. sess . opts . debugging_opts . print_mono_items . is_some ( ) {
1081
- let mut item_to_cgus: FxHashMap < _ , Vec < _ > > = Default :: default ( ) ;
1082
-
1083
- for cgu in & codegen_units {
1084
- for ( & mono_item, & linkage) in cgu. items ( ) {
1085
- item_to_cgus. entry ( mono_item)
1086
- . or_default ( )
1087
- . push ( ( cgu. name ( ) . clone ( ) , linkage) ) ;
1088
- }
1089
- }
1090
-
1091
- let mut item_keys: Vec < _ > = items
1092
- . iter ( )
1093
- . map ( |i| {
1094
- let mut output = i. to_string ( tcx) ;
1095
- output. push_str ( " @@" ) ;
1096
- let mut empty = Vec :: new ( ) ;
1097
- let cgus = item_to_cgus. get_mut ( i) . unwrap_or ( & mut empty) ;
1098
- cgus. as_mut_slice ( ) . sort_by_key ( |& ( ref name, _) | name. clone ( ) ) ;
1099
- cgus. dedup ( ) ;
1100
- for & ( ref cgu_name, ( linkage, _) ) in cgus. iter ( ) {
1101
- output. push_str ( " " ) ;
1102
- output. push_str ( & cgu_name. as_str ( ) ) ;
1103
-
1104
- let linkage_abbrev = match linkage {
1105
- Linkage :: External => "External" ,
1106
- Linkage :: AvailableExternally => "Available" ,
1107
- Linkage :: LinkOnceAny => "OnceAny" ,
1108
- Linkage :: LinkOnceODR => "OnceODR" ,
1109
- Linkage :: WeakAny => "WeakAny" ,
1110
- Linkage :: WeakODR => "WeakODR" ,
1111
- Linkage :: Appending => "Appending" ,
1112
- Linkage :: Internal => "Internal" ,
1113
- Linkage :: Private => "Private" ,
1114
- Linkage :: ExternalWeak => "ExternalWeak" ,
1115
- Linkage :: Common => "Common" ,
1116
- } ;
1117
-
1118
- output. push_str ( "[" ) ;
1119
- output. push_str ( linkage_abbrev) ;
1120
- output. push_str ( "]" ) ;
1121
- }
1122
- output
1123
- } )
1124
- . collect ( ) ;
1125
-
1126
- item_keys. sort ( ) ;
1127
-
1128
- for item in item_keys {
1129
- println ! ( "MONO_ITEM {}" , item) ;
1130
- }
1131
- }
1132
-
1133
- ( Arc :: new ( mono_items) , Arc :: new ( codegen_units) )
1134
- }
1135
-
1136
1012
impl CrateInfo {
1137
1013
pub fn new ( tcx : TyCtxt ) -> CrateInfo {
1138
1014
let mut info = CrateInfo {
@@ -1222,12 +1098,6 @@ impl CrateInfo {
1222
1098
}
1223
1099
}
1224
1100
1225
- fn is_codegened_item ( tcx : TyCtxt , id : DefId ) -> bool {
1226
- let ( all_mono_items, _) =
1227
- tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
1228
- all_mono_items. contains ( & id)
1229
- }
1230
-
1231
1101
fn compile_codegen_unit < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1232
1102
cgu_name : InternedString )
1233
1103
-> Stats {
@@ -1318,24 +1188,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1318
1188
}
1319
1189
}
1320
1190
1321
- pub fn provide ( providers : & mut Providers ) {
1322
- providers. collect_and_partition_mono_items =
1323
- collect_and_partition_mono_items;
1324
-
1325
- providers. is_codegened_item = is_codegened_item;
1326
-
1327
- providers. codegen_unit = |tcx, name| {
1328
- let ( _, all) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
1329
- all. iter ( )
1330
- . find ( |cgu| * cgu. name ( ) == name)
1331
- . cloned ( )
1332
- . unwrap_or_else ( || panic ! ( "failed to find cgu with name {:?}" , name) )
1333
- } ;
1334
-
1335
- provide_extern ( providers) ;
1336
- }
1337
-
1338
- pub fn provide_extern ( providers : & mut Providers ) {
1191
+ pub fn provide_both ( providers : & mut Providers ) {
1339
1192
providers. dllimport_foreign_items = |tcx, krate| {
1340
1193
let module_map = tcx. foreign_modules ( krate) ;
1341
1194
let module_map = module_map. iter ( )
0 commit comments