@@ -79,11 +79,7 @@ fn emit_module(
7979 )
8080}
8181
82- fn reuse_workproduct_for_cgu (
83- tcx : TyCtxt < ' _ > ,
84- cgu : & CodegenUnit < ' _ > ,
85- work_products : & mut FxHashMap < WorkProductId , WorkProduct > ,
86- ) -> CompiledModule {
82+ fn reuse_workproduct_for_cgu ( tcx : TyCtxt < ' _ > , cgu : & CodegenUnit < ' _ > ) -> ModuleCodegenResult {
8783 let work_product = cgu. previous_work_product ( tcx) ;
8884 let obj_out = tcx. output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( cgu. name ( ) . as_str ( ) ) ) ;
8985 let source_file = rustc_incremental:: in_incr_comp_dir_sess (
@@ -99,15 +95,16 @@ fn reuse_workproduct_for_cgu(
9995 ) ) ;
10096 }
10197
102- work_products. insert ( cgu. work_product_id ( ) , work_product) ;
103-
104- CompiledModule {
105- name : cgu. name ( ) . to_string ( ) ,
106- kind : ModuleKind :: Regular ,
107- object : Some ( obj_out) ,
108- dwarf_object : None ,
109- bytecode : None ,
110- }
98+ ModuleCodegenResult (
99+ CompiledModule {
100+ name : cgu. name ( ) . to_string ( ) ,
101+ kind : ModuleKind :: Regular ,
102+ object : Some ( obj_out) ,
103+ dwarf_object : None ,
104+ bytecode : None ,
105+ } ,
106+ Some ( ( cgu. work_product_id ( ) , work_product) ) ,
107+ )
111108}
112109
113110fn module_codegen (
@@ -215,26 +212,31 @@ pub(crate) fn run_aot(
215212 let modules = super :: time ( tcx, backend_config. display_cg_time , "codegen mono items" , || {
216213 cgus. iter ( )
217214 . map ( |cgu| {
218- let cgu_reuse = determine_cgu_reuse ( tcx, cgu) ;
215+ let cgu_reuse = if backend_config. disable_incr_cache {
216+ CguReuse :: No
217+ } else {
218+ determine_cgu_reuse ( tcx, cgu)
219+ } ;
219220 tcx. sess . cgu_reuse_tracker . set_actual_reuse ( cgu. name ( ) . as_str ( ) , cgu_reuse) ;
220221
221- match cgu_reuse {
222- _ if backend_config. disable_incr_cache => { }
223- CguReuse :: No => { }
224- CguReuse :: PreLto => {
225- return reuse_workproduct_for_cgu ( tcx, & * cgu, & mut work_products) ;
222+ let module_codegen_result = match cgu_reuse {
223+ CguReuse :: No => {
224+ let dep_node = cgu. codegen_dep_node ( tcx) ;
225+ tcx. dep_graph
226+ . with_task (
227+ dep_node,
228+ tcx,
229+ ( backend_config. clone ( ) , cgu. name ( ) ) ,
230+ module_codegen,
231+ Some ( rustc_middle:: dep_graph:: hash_result) ,
232+ )
233+ . 0
226234 }
235+ CguReuse :: PreLto => reuse_workproduct_for_cgu ( tcx, & * cgu) ,
227236 CguReuse :: PostLto => unreachable ! ( ) ,
228- }
237+ } ;
229238
230- let dep_node = cgu. codegen_dep_node ( tcx) ;
231- let ( ModuleCodegenResult ( module, work_product) , _) = tcx. dep_graph . with_task (
232- dep_node,
233- tcx,
234- ( backend_config. clone ( ) , cgu. name ( ) ) ,
235- module_codegen,
236- Some ( rustc_middle:: dep_graph:: hash_result) ,
237- ) ;
239+ let ModuleCodegenResult ( module, work_product) = module_codegen_result;
238240
239241 if let Some ( ( id, product) ) = work_product {
240242 work_products. insert ( id, product) ;
0 commit comments