@@ -1311,36 +1311,31 @@ fn execute_work_item(cgcx: &CodegenContext,
13111311 timeline : & mut Timeline )
13121312 -> Result < WorkItemResult , FatalError >
13131313{
1314+ let module_config = cgcx. config ( work_item. module_kind ( ) ) ;
1315+
13141316 match work_item {
1315- work_item @ WorkItem :: Optimize ( _ ) => {
1316- execute_optimize_work_item ( cgcx, work_item , timeline)
1317+ WorkItem :: Optimize ( module ) => {
1318+ execute_optimize_work_item ( cgcx, module , module_config , timeline)
13171319 }
1318- work_item @ WorkItem :: CopyPostLtoArtifacts ( _ ) => {
1319- execute_copy_from_cache_work_item ( cgcx, work_item , timeline)
1320+ WorkItem :: CopyPostLtoArtifacts ( module ) => {
1321+ execute_copy_from_cache_work_item ( cgcx, module , module_config , timeline)
13201322 }
1321- work_item @ WorkItem :: LTO ( _ ) => {
1322- execute_lto_work_item ( cgcx, work_item , timeline)
1323+ WorkItem :: LTO ( module ) => {
1324+ execute_lto_work_item ( cgcx, module , module_config , timeline)
13231325 }
13241326 }
13251327}
13261328
13271329fn execute_optimize_work_item ( cgcx : & CodegenContext ,
1328- work_item : WorkItem ,
1330+ module : ModuleCodegen ,
1331+ module_config : & ModuleConfig ,
13291332 timeline : & mut Timeline )
13301333 -> Result < WorkItemResult , FatalError >
13311334{
1332- let config = cgcx. config ( work_item. module_kind ( ) ) ;
1333-
1334- let module = if let WorkItem :: Optimize ( module) = work_item {
1335- module
1336- } else {
1337- bug ! ( "execute_optimize_work_item() called with non-WorkItem::Optimize" ) ;
1338- } ;
1339-
13401335 let diag_handler = cgcx. create_diag_handler ( ) ;
13411336
13421337 unsafe {
1343- optimize ( cgcx, & diag_handler, & module, config , timeline) ?;
1338+ optimize ( cgcx, & diag_handler, & module, module_config , timeline) ?;
13441339 }
13451340
13461341 let linker_does_lto = cgcx. opts . debugging_opts . cross_lang_lto . enabled ( ) ;
@@ -1394,25 +1389,18 @@ fn execute_optimize_work_item(cgcx: &CodegenContext,
13941389 Ok ( WorkItemResult :: NeedsLTO ( module) )
13951390 } else {
13961391 let module = unsafe {
1397- codegen ( cgcx, & diag_handler, module, config , timeline) ?
1392+ codegen ( cgcx, & diag_handler, module, module_config , timeline) ?
13981393 } ;
13991394 Ok ( WorkItemResult :: Compiled ( module) )
14001395 }
14011396}
14021397
14031398fn execute_copy_from_cache_work_item ( cgcx : & CodegenContext ,
1404- work_item : WorkItem ,
1399+ module : CachedModuleCodegen ,
1400+ module_config : & ModuleConfig ,
14051401 _: & mut Timeline )
14061402 -> Result < WorkItemResult , FatalError >
14071403{
1408- let config = cgcx. config ( work_item. module_kind ( ) ) ;
1409-
1410- let module = if let WorkItem :: CopyPostLtoArtifacts ( module) = work_item {
1411- module
1412- } else {
1413- bug ! ( "execute_copy_from_cache_work_item() called with wrong WorkItem kind." )
1414- } ;
1415-
14161404 let incr_comp_session_dir = cgcx. incr_comp_session_dir
14171405 . as_ref ( )
14181406 . unwrap ( ) ;
@@ -1459,9 +1447,9 @@ fn execute_copy_from_cache_work_item(cgcx: &CodegenContext,
14591447 }
14601448 }
14611449
1462- assert_eq ! ( object. is_some( ) , config . emit_obj) ;
1463- assert_eq ! ( bytecode. is_some( ) , config . emit_bc) ;
1464- assert_eq ! ( bytecode_compressed. is_some( ) , config . emit_bc_compressed) ;
1450+ assert_eq ! ( object. is_some( ) , module_config . emit_obj) ;
1451+ assert_eq ! ( bytecode. is_some( ) , module_config . emit_bc) ;
1452+ assert_eq ! ( bytecode_compressed. is_some( ) , module_config . emit_bc_compressed) ;
14651453
14661454 Ok ( WorkItemResult :: Compiled ( CompiledModule {
14671455 name : module. name ,
@@ -1473,22 +1461,17 @@ fn execute_copy_from_cache_work_item(cgcx: &CodegenContext,
14731461}
14741462
14751463fn execute_lto_work_item ( cgcx : & CodegenContext ,
1476- work_item : WorkItem ,
1464+ mut module : lto:: LtoModuleCodegen ,
1465+ module_config : & ModuleConfig ,
14771466 timeline : & mut Timeline )
14781467 -> Result < WorkItemResult , FatalError >
14791468{
1480- let config = cgcx. config ( work_item. module_kind ( ) ) ;
1481-
1482- if let WorkItem :: LTO ( mut lto) = work_item {
1483- let diag_handler = cgcx. create_diag_handler ( ) ;
1469+ let diag_handler = cgcx. create_diag_handler ( ) ;
14841470
1485- unsafe {
1486- let module = lto. optimize ( cgcx, timeline) ?;
1487- let module = codegen ( cgcx, & diag_handler, module, config, timeline) ?;
1488- Ok ( WorkItemResult :: Compiled ( module) )
1489- }
1490- } else {
1491- bug ! ( "execute_lto_work_item() called with wrong WorkItem kind." )
1471+ unsafe {
1472+ let module = module. optimize ( cgcx, timeline) ?;
1473+ let module = codegen ( cgcx, & diag_handler, module, module_config, timeline) ?;
1474+ Ok ( WorkItemResult :: Compiled ( module) )
14921475 }
14931476}
14941477
0 commit comments