@@ -349,8 +349,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
349349 /// Directory into which should the LLVM optimization remarks be written.
350350 /// If `None`, they will be written to stderr.
351351 pub remark_dir : Option < PathBuf > ,
352- /// Worker thread number
353- pub worker : usize ,
354352 /// The incremental compilation session directory, or None if we are not
355353 /// compiling incrementally
356354 pub incr_comp_session_dir : Option < PathBuf > ,
@@ -1104,7 +1102,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11041102 exported_symbols,
11051103 remark : sess. opts . cg . remark . clone ( ) ,
11061104 remark_dir,
1107- worker : 0 ,
11081105 incr_comp_session_dir : sess. incr_comp_session_dir_opt ( ) . map ( |r| r. clone ( ) ) ,
11091106 cgu_reuse_tracker : sess. cgu_reuse_tracker . clone ( ) ,
11101107 coordinator_send,
@@ -1355,17 +1352,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
13551352 // LLVM work too.
13561353 let ( item, _) =
13571354 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- } ;
13621355 maybe_start_llvm_timer (
13631356 prof,
13641357 cgcx. config ( item. module_kind ( ) ) ,
13651358 & mut llvm_start_time,
13661359 ) ;
13671360 main_thread_state = MainThreadState :: Lending ;
1368- spawn_work ( cgcx, item) ;
1361+ spawn_work ( & cgcx, get_worker_id ( & mut free_worker_ids ) , item) ;
13691362 }
13701363 }
13711364 } else if codegen_state == Completed {
@@ -1404,17 +1397,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
14041397 match main_thread_state {
14051398 MainThreadState :: Idle => {
14061399 if let Some ( ( item, _) ) = work_items. pop ( ) {
1407- let cgcx = CodegenContext {
1408- worker : get_worker_id ( & mut free_worker_ids) ,
1409- ..cgcx. clone ( )
1410- } ;
14111400 maybe_start_llvm_timer (
14121401 prof,
14131402 cgcx. config ( item. module_kind ( ) ) ,
14141403 & mut llvm_start_time,
14151404 ) ;
14161405 main_thread_state = MainThreadState :: Lending ;
1417- spawn_work ( cgcx, item) ;
1406+ spawn_work ( & cgcx, get_worker_id ( & mut free_worker_ids ) , item) ;
14181407 } else {
14191408 // There is no unstarted work, so let the main thread
14201409 // take over for a running worker. Otherwise the
@@ -1450,11 +1439,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14501439 let ( item, _) = work_items. pop ( ) . unwrap ( ) ;
14511440
14521441 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) ;
14581443 running_with_own_token += 1 ;
14591444 }
14601445
@@ -1700,7 +1685,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
17001685#[ must_use]
17011686pub struct WorkerFatalError ;
17021687
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+
17041695 B :: spawn_named_thread ( cgcx. time_trace , work. short_description ( ) , move || {
17051696 // Set up a destructor which will fire off a message that we're done as
17061697 // we exit.
@@ -1723,11 +1714,8 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
17231714 }
17241715 }
17251716
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 } ;
17311719
17321720 // Execute the work itself, and if it finishes successfully then flag
17331721 // ourselves as a success as well.
0 commit comments