Skip to content

Commit a077dbd

Browse files
committed
Better timers for LTO
1 parent 53867f2 commit a077dbd

File tree

1 file changed

+7
-12
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+7
-12
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ fn do_fat_lto<B: ExtraBackendMethods>(
992992
mut needs_fat_lto: Vec<FatLtoInput<B>>,
993993
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
994994
) -> CompiledModule {
995-
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", "everything");
995+
let _timer = cgcx.prof.verbose_generic_activity("LLVM_fatlto");
996996

997997
check_lto_allowed(&cgcx);
998998

@@ -1011,7 +1011,6 @@ fn do_fat_lto<B: ExtraBackendMethods>(
10111011

10121012
fn do_thin_lto<'a, B: ExtraBackendMethods>(
10131013
cgcx: &'a CodegenContext<B>,
1014-
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
10151014
exported_symbols_for_lto: Arc<Vec<String>>,
10161015
each_linked_rlib_for_lto: Vec<PathBuf>,
10171016
needs_thin_lto: Vec<(String, <B as WriteBackendMethods>::ThinBuffer)>,
@@ -1020,6 +1019,8 @@ fn do_thin_lto<'a, B: ExtraBackendMethods>(
10201019
WorkProduct,
10211020
)>,
10221021
) -> Vec<CompiledModule> {
1022+
let _timer = cgcx.prof.verbose_generic_activity("LLVM_thinlto");
1023+
10231024
check_lto_allowed(&cgcx);
10241025

10251026
let (coordinator_send, coordinator_receive) = channel();
@@ -1086,7 +1087,7 @@ fn do_thin_lto<'a, B: ExtraBackendMethods>(
10861087
while used_token_count < tokens.len() + 1
10871088
&& let Some((item, _)) = work_items.pop()
10881089
{
1089-
spawn_thin_lto_work(&cgcx, coordinator_send.clone(), llvm_start_time, item);
1090+
spawn_thin_lto_work(&cgcx, coordinator_send.clone(), item);
10901091
used_token_count += 1;
10911092
}
10921093
} else {
@@ -1726,6 +1727,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
17261727
}
17271728
}
17281729

1730+
// Drop to print timings
1731+
drop(llvm_start_time);
1732+
17291733
if codegen_state == Aborted {
17301734
return Err(());
17311735
}
@@ -1754,17 +1758,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
17541758

17551759
compiled_modules.extend(do_thin_lto(
17561760
&cgcx,
1757-
&mut llvm_start_time,
17581761
exported_symbols_for_lto,
17591762
each_linked_rlib_file_for_lto,
17601763
needs_thin_lto,
17611764
lto_import_only_modules,
17621765
));
17631766
}
17641767

1765-
// Drop to print timings
1766-
drop(llvm_start_time);
1767-
17681768
// Regardless of what order these modules completed in, report them to
17691769
// the backend in the same order every time to ensure that we're handing
17701770
// out deterministic results.
@@ -1879,13 +1879,8 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18791879
fn spawn_thin_lto_work<'a, B: ExtraBackendMethods>(
18801880
cgcx: &'a CodegenContext<B>,
18811881
coordinator_send: Sender<ThinLtoMessage>,
1882-
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
18831882
work: ThinLtoWorkItem<B>,
18841883
) {
1885-
if llvm_start_time.is_none() {
1886-
*llvm_start_time = Some(cgcx.prof.verbose_generic_activity("LLVM_passes"));
1887-
}
1888-
18891884
let cgcx = cgcx.clone();
18901885

18911886
B::spawn_named_thread(cgcx.time_trace, work.short_description(), move || {

0 commit comments

Comments
 (0)