@@ -891,7 +891,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
891
891
& format ! ( "codegen {}" , cgu. name( ) ) )
892
892
} ) ;
893
893
let start_time = Instant :: now ( ) ;
894
- all_stats. extend ( tcx . compile_codegen_unit ( * cgu. name ( ) ) ) ;
894
+ all_stats. extend ( compile_codegen_unit ( tcx , * cgu. name ( ) ) ) ;
895
895
total_codegen_time += start_time. elapsed ( ) ;
896
896
ongoing_codegen. check_for_errors ( tcx. sess ) ;
897
897
}
@@ -1157,11 +1157,15 @@ fn is_codegened_item(tcx: TyCtxt, id: DefId) -> bool {
1157
1157
}
1158
1158
1159
1159
fn compile_codegen_unit < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1160
- cgu : InternedString ) -> Stats {
1161
- let cgu = tcx. codegen_unit ( cgu) ;
1162
-
1160
+ cgu_name : InternedString )
1161
+ -> Stats {
1163
1162
let start_time = Instant :: now ( ) ;
1164
- let ( stats, module) = module_codegen ( tcx, cgu) ;
1163
+
1164
+ let dep_node = tcx. codegen_unit ( cgu_name) . codegen_dep_node ( tcx) ;
1165
+ let ( ( stats, module) , _) = tcx. dep_graph . with_task ( dep_node,
1166
+ tcx,
1167
+ cgu_name,
1168
+ module_codegen) ;
1165
1169
let time_to_codegen = start_time. elapsed ( ) ;
1166
1170
1167
1171
// We assume that the cost to run LLVM on a CGU is proportional to
@@ -1170,23 +1174,29 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1170
1174
time_to_codegen. subsec_nanos ( ) as u64 ;
1171
1175
1172
1176
write:: submit_codegened_module_to_llvm ( tcx,
1173
- module,
1174
- cost) ;
1177
+ module,
1178
+ cost) ;
1179
+
1180
+ if tcx. dep_graph . is_fully_enabled ( ) {
1181
+ let dep_node_index = tcx. dep_graph . dep_node_index_of ( & dep_node) ;
1182
+ tcx. dep_graph . mark_loaded_from_cache ( dep_node_index, false ) ;
1183
+ }
1184
+
1175
1185
return stats;
1176
1186
1177
1187
fn module_codegen < ' a , ' tcx > (
1178
1188
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1179
- cgu : Arc < CodegenUnit < ' tcx > > )
1189
+ cgu_name : InternedString )
1180
1190
-> ( Stats , ModuleCodegen )
1181
1191
{
1182
- let cgu_name = cgu . name ( ) . to_string ( ) ;
1192
+ let cgu = tcx . codegen_unit ( cgu_name ) ;
1183
1193
1184
1194
// Instantiate monomorphizations without filling out definitions yet...
1185
- let llvm_module = ModuleLlvm :: new ( tcx. sess , & cgu_name) ;
1195
+ let llvm_module = ModuleLlvm :: new ( tcx. sess , & cgu_name. as_str ( ) ) ;
1186
1196
let stats = {
1187
1197
let cx = CodegenCx :: new ( tcx, cgu, & llvm_module) ;
1188
1198
let mono_items = cx. codegen_unit
1189
- . items_in_deterministic_order ( cx. tcx ) ;
1199
+ . items_in_deterministic_order ( cx. tcx ) ;
1190
1200
for & ( mono_item, ( linkage, visibility) ) in & mono_items {
1191
1201
mono_item. predefine ( & cx, linkage, visibility) ;
1192
1202
}
@@ -1235,7 +1245,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1235
1245
} ;
1236
1246
1237
1247
( stats, ModuleCodegen {
1238
- name : cgu_name,
1248
+ name : cgu_name. to_string ( ) ,
1239
1249
source : ModuleSource :: Codegened ( llvm_module) ,
1240
1250
kind : ModuleKind :: Regular ,
1241
1251
} )
@@ -1255,7 +1265,6 @@ pub fn provide(providers: &mut Providers) {
1255
1265
. cloned ( )
1256
1266
. unwrap_or_else ( || panic ! ( "failed to find cgu with name {:?}" , name) )
1257
1267
} ;
1258
- providers. compile_codegen_unit = compile_codegen_unit;
1259
1268
1260
1269
provide_extern ( providers) ;
1261
1270
}
0 commit comments