Skip to content

Commit b075ea9

Browse files
committed
Move timers into execute_*_work_item
1 parent a5ff397 commit b075ea9

File tree

1 file changed

+20
-27
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+20
-27
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
822822
cgcx: &CodegenContext<B>,
823823
mut module: ModuleCodegen<B::Module>,
824824
) -> WorkItemResult<B> {
825+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_optimize", &*module.name);
826+
825827
let dcx = cgcx.create_dcx();
826828
let dcx = dcx.handle();
827829

@@ -877,6 +879,10 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
877879
cgcx: &CodegenContext<B>,
878880
module: CachedModuleCodegen,
879881
) -> WorkItemResult<B> {
882+
let _timer = cgcx
883+
.prof
884+
.generic_activity_with_arg("codegen_copy_artifacts_from_incr_cache", &*module.name);
885+
880886
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
881887

882888
let mut links_from_incr_cache = Vec::new();
@@ -963,6 +969,8 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
963969
mut needs_fat_lto: Vec<FatLtoInput<B>>,
964970
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
965971
) -> WorkItemResult<B> {
972+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", "everything");
973+
966974
for (module, wp) in import_only_modules {
967975
needs_fat_lto.push(FatLtoInput::Serialized { name: wp.cgu_name, buffer: module })
968976
}
@@ -981,6 +989,8 @@ fn execute_thin_lto_work_item<B: ExtraBackendMethods>(
981989
cgcx: &CodegenContext<B>,
982990
module: lto::ThinModule<B>,
983991
) -> WorkItemResult<B> {
992+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", module.name());
993+
984994
let module = B::optimize_thin(cgcx, module);
985995
let module = B::codegen(cgcx, module, &cgcx.module_config);
986996
WorkItemResult::Finished(module)
@@ -1693,38 +1703,21 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
16931703

16941704
B::spawn_named_thread(cgcx.time_trace, work.short_description(), move || {
16951705
let result = std::panic::catch_unwind(AssertUnwindSafe(|| match work {
1696-
WorkItem::Optimize(m) => {
1697-
let _timer =
1698-
cgcx.prof.generic_activity_with_arg("codegen_module_optimize", &*m.name);
1699-
execute_optimize_work_item(&cgcx, m)
1700-
}
1701-
WorkItem::CopyPostLtoArtifacts(m) => {
1702-
let _timer = cgcx
1703-
.prof
1704-
.generic_activity_with_arg("codegen_copy_artifacts_from_incr_cache", &*m.name);
1705-
execute_copy_from_cache_work_item(&cgcx, m)
1706-
}
1706+
WorkItem::Optimize(m) => execute_optimize_work_item(&cgcx, m),
1707+
WorkItem::CopyPostLtoArtifacts(m) => execute_copy_from_cache_work_item(&cgcx, m),
17071708
WorkItem::FatLto {
17081709
exported_symbols_for_lto,
17091710
each_linked_rlib_for_lto,
17101711
needs_fat_lto,
17111712
import_only_modules,
1712-
} => {
1713-
let _timer =
1714-
cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", "everything");
1715-
execute_fat_lto_work_item(
1716-
&cgcx,
1717-
&exported_symbols_for_lto,
1718-
&each_linked_rlib_for_lto,
1719-
needs_fat_lto,
1720-
import_only_modules,
1721-
)
1722-
}
1723-
WorkItem::ThinLto(m) => {
1724-
let _timer =
1725-
cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", m.name());
1726-
execute_thin_lto_work_item(&cgcx, m)
1727-
}
1713+
} => execute_fat_lto_work_item(
1714+
&cgcx,
1715+
&exported_symbols_for_lto,
1716+
&each_linked_rlib_for_lto,
1717+
needs_fat_lto,
1718+
import_only_modules,
1719+
),
1720+
WorkItem::ThinLto(m) => execute_thin_lto_work_item(&cgcx, m),
17281721
}));
17291722

17301723
let msg = match result {

0 commit comments

Comments
 (0)