@@ -349,8 +349,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
349
349
/// Directory into which should the LLVM optimization remarks be written.
350
350
/// If `None`, they will be written to stderr.
351
351
pub remark_dir : Option < PathBuf > ,
352
- /// Worker thread number
353
- pub worker : usize ,
354
352
/// The incremental compilation session directory, or None if we are not
355
353
/// compiling incrementally
356
354
pub incr_comp_session_dir : Option < PathBuf > ,
@@ -1104,7 +1102,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1104
1102
exported_symbols,
1105
1103
remark : sess. opts . cg . remark . clone ( ) ,
1106
1104
remark_dir,
1107
- worker : 0 ,
1108
1105
incr_comp_session_dir : sess. incr_comp_session_dir_opt ( ) . map ( |r| r. clone ( ) ) ,
1109
1106
cgu_reuse_tracker : sess. cgu_reuse_tracker . clone ( ) ,
1110
1107
coordinator_send,
@@ -1355,17 +1352,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
1355
1352
// LLVM work too.
1356
1353
let ( item, _) =
1357
1354
work_items. pop ( ) . expect ( "queue empty - queue_full_enough() broken?" ) ;
1358
- let cgcx = CodegenContext {
1359
- worker : get_worker_id ( & mut free_worker_ids) ,
1360
- ..cgcx. clone ( )
1361
- } ;
1362
1355
maybe_start_llvm_timer (
1363
1356
prof,
1364
1357
cgcx. config ( item. module_kind ( ) ) ,
1365
1358
& mut llvm_start_time,
1366
1359
) ;
1367
1360
main_thread_state = MainThreadState :: Lending ;
1368
- spawn_work ( cgcx, item) ;
1361
+ spawn_work ( & cgcx, get_worker_id ( & mut free_worker_ids ) , item) ;
1369
1362
}
1370
1363
}
1371
1364
} else if codegen_state == Completed {
@@ -1404,17 +1397,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
1404
1397
match main_thread_state {
1405
1398
MainThreadState :: Idle => {
1406
1399
if let Some ( ( item, _) ) = work_items. pop ( ) {
1407
- let cgcx = CodegenContext {
1408
- worker : get_worker_id ( & mut free_worker_ids) ,
1409
- ..cgcx. clone ( )
1410
- } ;
1411
1400
maybe_start_llvm_timer (
1412
1401
prof,
1413
1402
cgcx. config ( item. module_kind ( ) ) ,
1414
1403
& mut llvm_start_time,
1415
1404
) ;
1416
1405
main_thread_state = MainThreadState :: Lending ;
1417
- spawn_work ( cgcx, item) ;
1406
+ spawn_work ( & cgcx, get_worker_id ( & mut free_worker_ids ) , item) ;
1418
1407
} else {
1419
1408
// There is no unstarted work, so let the main thread
1420
1409
// take over for a running worker. Otherwise the
@@ -1450,11 +1439,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1450
1439
let ( item, _) = work_items. pop ( ) . unwrap ( ) ;
1451
1440
1452
1441
maybe_start_llvm_timer ( prof, cgcx. config ( item. module_kind ( ) ) , & mut llvm_start_time) ;
1453
-
1454
- let cgcx =
1455
- CodegenContext { worker : get_worker_id ( & mut free_worker_ids) , ..cgcx. clone ( ) } ;
1456
-
1457
- spawn_work ( cgcx, item) ;
1442
+ spawn_work ( & cgcx, get_worker_id ( & mut free_worker_ids) , item) ;
1458
1443
running_with_own_token += 1 ;
1459
1444
}
1460
1445
@@ -1700,7 +1685,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
1700
1685
#[ must_use]
1701
1686
pub struct WorkerFatalError ;
1702
1687
1703
- fn spawn_work < B : ExtraBackendMethods > ( cgcx : CodegenContext < B > , work : WorkItem < B > ) {
1688
+ fn spawn_work < B : ExtraBackendMethods > (
1689
+ cgcx : & CodegenContext < B > ,
1690
+ worker_id : usize ,
1691
+ work : WorkItem < B > ,
1692
+ ) {
1693
+ let cgcx = cgcx. clone ( ) ;
1694
+
1704
1695
B :: spawn_named_thread ( cgcx. time_trace , work. short_description ( ) , move || {
1705
1696
// Set up a destructor which will fire off a message that we're done as
1706
1697
// we exit.
@@ -1723,11 +1714,8 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
1723
1714
}
1724
1715
}
1725
1716
1726
- let mut bomb = Bomb :: < B > {
1727
- coordinator_send : cgcx. coordinator_send . clone ( ) ,
1728
- result : None ,
1729
- worker_id : cgcx. worker ,
1730
- } ;
1717
+ let mut bomb =
1718
+ Bomb :: < B > { coordinator_send : cgcx. coordinator_send . clone ( ) , result : None , worker_id } ;
1731
1719
1732
1720
// Execute the work itself, and if it finishes successfully then flag
1733
1721
// ourselves as a success as well.
0 commit comments