@@ -1311,36 +1311,31 @@ fn execute_work_item(cgcx: &CodegenContext,
1311
1311
timeline : & mut Timeline )
1312
1312
-> Result < WorkItemResult , FatalError >
1313
1313
{
1314
+ let module_config = cgcx. config ( work_item. module_kind ( ) ) ;
1315
+
1314
1316
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)
1317
1319
}
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)
1320
1322
}
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)
1323
1325
}
1324
1326
}
1325
1327
}
1326
1328
1327
1329
fn execute_optimize_work_item ( cgcx : & CodegenContext ,
1328
- work_item : WorkItem ,
1330
+ module : ModuleCodegen ,
1331
+ module_config : & ModuleConfig ,
1329
1332
timeline : & mut Timeline )
1330
1333
-> Result < WorkItemResult , FatalError >
1331
1334
{
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
-
1340
1335
let diag_handler = cgcx. create_diag_handler ( ) ;
1341
1336
1342
1337
unsafe {
1343
- optimize ( cgcx, & diag_handler, & module, config , timeline) ?;
1338
+ optimize ( cgcx, & diag_handler, & module, module_config , timeline) ?;
1344
1339
}
1345
1340
1346
1341
let linker_does_lto = cgcx. opts . debugging_opts . cross_lang_lto . enabled ( ) ;
@@ -1394,25 +1389,18 @@ fn execute_optimize_work_item(cgcx: &CodegenContext,
1394
1389
Ok ( WorkItemResult :: NeedsLTO ( module) )
1395
1390
} else {
1396
1391
let module = unsafe {
1397
- codegen ( cgcx, & diag_handler, module, config , timeline) ?
1392
+ codegen ( cgcx, & diag_handler, module, module_config , timeline) ?
1398
1393
} ;
1399
1394
Ok ( WorkItemResult :: Compiled ( module) )
1400
1395
}
1401
1396
}
1402
1397
1403
1398
fn execute_copy_from_cache_work_item ( cgcx : & CodegenContext ,
1404
- work_item : WorkItem ,
1399
+ module : CachedModuleCodegen ,
1400
+ module_config : & ModuleConfig ,
1405
1401
_: & mut Timeline )
1406
1402
-> Result < WorkItemResult , FatalError >
1407
1403
{
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
-
1416
1404
let incr_comp_session_dir = cgcx. incr_comp_session_dir
1417
1405
. as_ref ( )
1418
1406
. unwrap ( ) ;
@@ -1459,9 +1447,9 @@ fn execute_copy_from_cache_work_item(cgcx: &CodegenContext,
1459
1447
}
1460
1448
}
1461
1449
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) ;
1465
1453
1466
1454
Ok ( WorkItemResult :: Compiled ( CompiledModule {
1467
1455
name : module. name ,
@@ -1473,22 +1461,17 @@ fn execute_copy_from_cache_work_item(cgcx: &CodegenContext,
1473
1461
}
1474
1462
1475
1463
fn execute_lto_work_item ( cgcx : & CodegenContext ,
1476
- work_item : WorkItem ,
1464
+ mut module : lto:: LtoModuleCodegen ,
1465
+ module_config : & ModuleConfig ,
1477
1466
timeline : & mut Timeline )
1478
1467
-> Result < WorkItemResult , FatalError >
1479
1468
{
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 ( ) ;
1484
1470
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) )
1492
1475
}
1493
1476
}
1494
1477
0 commit comments