Skip to content
/ rust Public
forked from rust-lang/rust

Commit c696307

Browse files
committed
Inline and remove WorkItem::start_profiling and execute_work_item.
They both match on a `WorkItem`. It's simpler to do it all in one place.
1 parent 9397862 commit c696307

File tree

1 file changed

+22
-34
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+22
-34
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+22-34
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use jobserver::{Acquired, Client};
1111
use rustc_ast::attr;
1212
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
1313
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};
1715
use rustc_data_structures::sync::Lrc;
1816
use rustc_errors::emitter::Emitter;
1917
use rustc_errors::{translation::Translate, DiagnosticId, FatalError, Handler, Level};
@@ -705,20 +703,6 @@ impl<B: WriteBackendMethods> WorkItem<B> {
705703
}
706704
}
707705

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-
722706
/// Generate a short description of this work item suitable for use as a thread name.
723707
fn short_description(&self) -> String {
724708
// `pthread_setname()` on *nix is limited to 15 characters and longer names are ignored.
@@ -759,21 +743,6 @@ pub enum FatLTOInput<B: WriteBackendMethods> {
759743
InMemory(ModuleCodegen<B::Module>),
760744
}
761745

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-
777746
/// Actual LTO type we end up choosing based on multiple factors.
778747
pub enum ComputedLtoType {
779748
No,
@@ -1706,8 +1675,27 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
17061675
// as a diagnostic was already sent off to the main thread - just
17071676
// surface that there was an error in this worker.
17081677
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+
})
17111699
};
17121700
})
17131701
.expect("failed to spawn thread");

0 commit comments

Comments
 (0)