@@ -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,20 +63,19 @@ 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 ;
77
76
78
77
use std:: any:: Any ;
79
78
use std:: ffi:: CString ;
80
- use std:: sync:: Arc ;
81
79
use std:: time:: { Instant , Duration } ;
82
80
use std:: i32;
83
81
use std:: cmp;
@@ -962,128 +960,6 @@ fn assert_and_save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
962
960
|| rustc_incremental:: save_dep_graph ( tcx) ) ;
963
961
}
964
962
965
- fn collect_and_partition_mono_items < ' a , ' tcx > (
966
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
967
- cnum : CrateNum ,
968
- ) -> ( Arc < DefIdSet > , Arc < Vec < Arc < CodegenUnit < ' tcx > > > > )
969
- {
970
- assert_eq ! ( cnum, LOCAL_CRATE ) ;
971
-
972
- let collection_mode = match tcx. sess . opts . debugging_opts . print_mono_items {
973
- Some ( ref s) => {
974
- let mode_string = s. to_lowercase ( ) ;
975
- let mode_string = mode_string. trim ( ) ;
976
- if mode_string == "eager" {
977
- MonoItemCollectionMode :: Eager
978
- } else {
979
- if mode_string != "lazy" {
980
- let message = format ! ( "Unknown codegen-item collection mode '{}'. \
981
- Falling back to 'lazy' mode.",
982
- mode_string) ;
983
- tcx. sess . warn ( & message) ;
984
- }
985
-
986
- MonoItemCollectionMode :: Lazy
987
- }
988
- }
989
- None => {
990
- if tcx. sess . opts . cg . link_dead_code {
991
- MonoItemCollectionMode :: Eager
992
- } else {
993
- MonoItemCollectionMode :: Lazy
994
- }
995
- }
996
- } ;
997
-
998
- let ( items, inlining_map) =
999
- time ( tcx. sess , "monomorphization collection" , || {
1000
- collector:: collect_crate_mono_items ( tcx, collection_mode)
1001
- } ) ;
1002
-
1003
- tcx. sess . abort_if_errors ( ) ;
1004
-
1005
- :: rustc_mir:: monomorphize:: assert_symbols_are_distinct ( tcx, items. iter ( ) ) ;
1006
-
1007
- let strategy = if tcx. sess . opts . incremental . is_some ( ) {
1008
- PartitioningStrategy :: PerModule
1009
- } else {
1010
- PartitioningStrategy :: FixedUnitCount ( tcx. sess . codegen_units ( ) )
1011
- } ;
1012
-
1013
- let codegen_units = time ( tcx. sess , "codegen unit partitioning" , || {
1014
- partitioning:: partition ( tcx,
1015
- items. iter ( ) . cloned ( ) ,
1016
- strategy,
1017
- & inlining_map)
1018
- . into_iter ( )
1019
- . map ( Arc :: new)
1020
- . collect :: < Vec < _ > > ( )
1021
- } ) ;
1022
-
1023
- let mono_items: DefIdSet = items. iter ( ) . filter_map ( |mono_item| {
1024
- match * mono_item {
1025
- MonoItem :: Fn ( ref instance) => Some ( instance. def_id ( ) ) ,
1026
- MonoItem :: Static ( def_id) => Some ( def_id) ,
1027
- _ => None ,
1028
- }
1029
- } ) . collect ( ) ;
1030
-
1031
- if tcx. sess . opts . debugging_opts . print_mono_items . is_some ( ) {
1032
- let mut item_to_cgus: FxHashMap < _ , Vec < _ > > = Default :: default ( ) ;
1033
-
1034
- for cgu in & codegen_units {
1035
- for ( & mono_item, & linkage) in cgu. items ( ) {
1036
- item_to_cgus. entry ( mono_item)
1037
- . or_default ( )
1038
- . push ( ( cgu. name ( ) . clone ( ) , linkage) ) ;
1039
- }
1040
- }
1041
-
1042
- let mut item_keys: Vec < _ > = items
1043
- . iter ( )
1044
- . map ( |i| {
1045
- let mut output = i. to_string ( tcx) ;
1046
- output. push_str ( " @@" ) ;
1047
- let mut empty = Vec :: new ( ) ;
1048
- let cgus = item_to_cgus. get_mut ( i) . unwrap_or ( & mut empty) ;
1049
- cgus. as_mut_slice ( ) . sort_by_key ( |& ( ref name, _) | name. clone ( ) ) ;
1050
- cgus. dedup ( ) ;
1051
- for & ( ref cgu_name, ( linkage, _) ) in cgus. iter ( ) {
1052
- output. push_str ( " " ) ;
1053
- output. push_str ( & cgu_name. as_str ( ) ) ;
1054
-
1055
- let linkage_abbrev = match linkage {
1056
- Linkage :: External => "External" ,
1057
- Linkage :: AvailableExternally => "Available" ,
1058
- Linkage :: LinkOnceAny => "OnceAny" ,
1059
- Linkage :: LinkOnceODR => "OnceODR" ,
1060
- Linkage :: WeakAny => "WeakAny" ,
1061
- Linkage :: WeakODR => "WeakODR" ,
1062
- Linkage :: Appending => "Appending" ,
1063
- Linkage :: Internal => "Internal" ,
1064
- Linkage :: Private => "Private" ,
1065
- Linkage :: ExternalWeak => "ExternalWeak" ,
1066
- Linkage :: Common => "Common" ,
1067
- } ;
1068
-
1069
- output. push_str ( "[" ) ;
1070
- output. push_str ( linkage_abbrev) ;
1071
- output. push_str ( "]" ) ;
1072
- }
1073
- output
1074
- } )
1075
- . collect ( ) ;
1076
-
1077
- item_keys. sort ( ) ;
1078
-
1079
- for item in item_keys {
1080
- println ! ( "MONO_ITEM {}" , item) ;
1081
- }
1082
- }
1083
-
1084
- ( Arc :: new ( mono_items) , Arc :: new ( codegen_units) )
1085
- }
1086
-
1087
963
impl CrateInfo {
1088
964
pub fn new ( tcx : TyCtxt ) -> CrateInfo {
1089
965
let mut info = CrateInfo {
@@ -1173,12 +1049,6 @@ impl CrateInfo {
1173
1049
}
1174
1050
}
1175
1051
1176
- fn is_codegened_item ( tcx : TyCtxt , id : DefId ) -> bool {
1177
- let ( all_mono_items, _) =
1178
- tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
1179
- all_mono_items. contains ( & id)
1180
- }
1181
-
1182
1052
fn compile_codegen_unit < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1183
1053
cgu_name : InternedString )
1184
1054
-> Stats {
@@ -1269,24 +1139,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1269
1139
}
1270
1140
}
1271
1141
1272
- pub fn provide ( providers : & mut Providers ) {
1273
- providers. collect_and_partition_mono_items =
1274
- collect_and_partition_mono_items;
1275
-
1276
- providers. is_codegened_item = is_codegened_item;
1277
-
1278
- providers. codegen_unit = |tcx, name| {
1279
- let ( _, all) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
1280
- all. iter ( )
1281
- . find ( |cgu| * cgu. name ( ) == name)
1282
- . cloned ( )
1283
- . unwrap_or_else ( || panic ! ( "failed to find cgu with name {:?}" , name) )
1284
- } ;
1285
-
1286
- provide_extern ( providers) ;
1287
- }
1288
-
1289
- pub fn provide_extern ( providers : & mut Providers ) {
1142
+ pub fn provide_both ( providers : & mut Providers ) {
1290
1143
providers. dllimport_foreign_items = |tcx, krate| {
1291
1144
let module_map = tcx. foreign_modules ( krate) ;
1292
1145
let module_map = module_map. iter ( )
0 commit comments