@@ -11,9 +11,7 @@ use jobserver::{Acquired, Client};
11
11
use rustc_ast:: attr;
12
12
use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
13
13
use rustc_data_structures:: memmap:: Mmap ;
14
- use rustc_data_structures:: profiling:: SelfProfilerRef ;
15
- use rustc_data_structures:: profiling:: TimingGuard ;
16
- use rustc_data_structures:: profiling:: VerboseTimingGuard ;
14
+ use rustc_data_structures:: profiling:: { SelfProfilerRef , VerboseTimingGuard } ;
17
15
use rustc_data_structures:: sync:: Lrc ;
18
16
use rustc_errors:: emitter:: Emitter ;
19
17
use rustc_errors:: { translation:: Translate , DiagnosticId , FatalError , Handler , Level } ;
@@ -705,20 +703,6 @@ impl<B: WriteBackendMethods> WorkItem<B> {
705
703
}
706
704
}
707
705
708
- fn start_profiling < ' a > ( & self , cgcx : & ' a CodegenContext < B > ) -> TimingGuard < ' a > {
709
- match * self {
710
- WorkItem :: Optimize ( ref m) => {
711
- cgcx. prof . generic_activity_with_arg ( "codegen_module_optimize" , & * m. name )
712
- }
713
- WorkItem :: CopyPostLtoArtifacts ( ref m) => cgcx
714
- . prof
715
- . generic_activity_with_arg ( "codegen_copy_artifacts_from_incr_cache" , & * m. name ) ,
716
- WorkItem :: LTO ( ref m) => {
717
- cgcx. prof . generic_activity_with_arg ( "codegen_module_perform_lto" , m. name ( ) )
718
- }
719
- }
720
- }
721
-
722
706
/// Generate a short description of this work item suitable for use as a thread name.
723
707
fn short_description ( & self ) -> String {
724
708
// `pthread_setname()` on *nix is limited to 15 characters and longer names are ignored.
@@ -759,21 +743,6 @@ pub enum FatLTOInput<B: WriteBackendMethods> {
759
743
InMemory ( ModuleCodegen < B :: Module > ) ,
760
744
}
761
745
762
- fn execute_work_item < B : ExtraBackendMethods > (
763
- cgcx : & CodegenContext < B > ,
764
- work_item : WorkItem < B > ,
765
- ) -> Result < WorkItemResult < B > , FatalError > {
766
- let module_config = cgcx. config ( work_item. module_kind ( ) ) ;
767
-
768
- match work_item {
769
- WorkItem :: Optimize ( module) => execute_optimize_work_item ( cgcx, module, module_config) ,
770
- WorkItem :: CopyPostLtoArtifacts ( module) => {
771
- Ok ( execute_copy_from_cache_work_item ( cgcx, module, module_config) )
772
- }
773
- WorkItem :: LTO ( module) => execute_lto_work_item ( cgcx, module, module_config) ,
774
- }
775
- }
776
-
777
746
/// Actual LTO type we end up choosing based on multiple factors.
778
747
pub enum ComputedLtoType {
779
748
No ,
@@ -1706,8 +1675,27 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
1706
1675
// as a diagnostic was already sent off to the main thread - just
1707
1676
// surface that there was an error in this worker.
1708
1677
bomb. result = {
1709
- let _prof_timer = work. start_profiling ( & cgcx) ;
1710
- Some ( execute_work_item ( & cgcx, work) )
1678
+ let module_config = cgcx. config ( work. module_kind ( ) ) ;
1679
+
1680
+ Some ( match work {
1681
+ WorkItem :: Optimize ( m) => {
1682
+ let _timer =
1683
+ cgcx. prof . generic_activity_with_arg ( "codegen_module_optimize" , & * m. name ) ;
1684
+ execute_optimize_work_item ( & cgcx, m, module_config)
1685
+ }
1686
+ WorkItem :: CopyPostLtoArtifacts ( m) => {
1687
+ let _timer = cgcx. prof . generic_activity_with_arg (
1688
+ "codegen_copy_artifacts_from_incr_cache" ,
1689
+ & * m. name ,
1690
+ ) ;
1691
+ Ok ( execute_copy_from_cache_work_item ( & cgcx, m, module_config) )
1692
+ }
1693
+ WorkItem :: LTO ( m) => {
1694
+ let _timer =
1695
+ cgcx. prof . generic_activity_with_arg ( "codegen_module_perform_lto" , m. name ( ) ) ;
1696
+ execute_lto_work_item ( & cgcx, m, module_config)
1697
+ }
1698
+ } )
1711
1699
} ;
1712
1700
} )
1713
1701
. expect ( "failed to spawn thread" ) ;
0 commit comments