Skip to content

Commit 2472d19

Browse files
committed
Include allocator module in LLVM_passes timer
1 parent dc0bae1 commit 2472d19

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub struct ModuleConfig {
110110
pub lint_llvm_ir: bool,
111111
pub no_prepopulate_passes: bool,
112112
pub no_builtins: bool,
113-
pub time_module: bool,
114113
pub vectorize_loop: bool,
115114
pub vectorize_slp: bool,
116115
pub merge_functions: bool,
@@ -228,10 +227,6 @@ impl ModuleConfig {
228227
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
229228
no_builtins: no_builtins || sess.target.no_builtins,
230229

231-
// Exclude metadata and allocator modules from time_passes output,
232-
// since they throw off the "LLVM passes" measurement.
233-
time_module: if_regular!(true, false),
234-
235230
// Copy what clang does by turning on loop vectorization at O2 and
236231
// slp vectorization at O3.
237232
vectorize_loop: !sess.opts.cg.no_vectorize_loops
@@ -1740,7 +1735,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
17401735
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
17411736
work: WorkItem<B>,
17421737
) {
1743-
if cgcx.config(work.module_kind()).time_module && llvm_start_time.is_none() {
1738+
if llvm_start_time.is_none() {
17441739
*llvm_start_time = Some(cgcx.prof.verbose_generic_activity("LLVM_passes"));
17451740
}
17461741

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -681,33 +681,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
681681

682682
let ongoing_codegen = start_async_codegen(backend.clone(), tcx, target_cpu, autodiff_items);
683683

684-
// Codegen an allocator shim, if necessary.
685-
if let Some(kind) = allocator_kind_for_codegen(tcx) {
686-
let llmod_id =
687-
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
688-
let module_llvm = tcx.sess.time("write_allocator_module", || {
689-
backend.codegen_allocator(
690-
tcx,
691-
&llmod_id,
692-
kind,
693-
// If allocator_kind is Some then alloc_error_handler_kind must
694-
// also be Some.
695-
tcx.alloc_error_handler_kind(()).unwrap(),
696-
)
697-
});
698-
699-
ongoing_codegen.wait_for_signal_to_codegen_item();
700-
ongoing_codegen.check_for_errors(tcx.sess);
701-
702-
// These modules are generally cheap and won't throw off scheduling.
703-
let cost = 0;
704-
submit_codegened_module_to_llvm(
705-
&ongoing_codegen.coordinator,
706-
ModuleCodegen::new_allocator(llmod_id, module_llvm),
707-
cost,
708-
);
709-
}
710-
711684
// For better throughput during parallel processing by LLVM, we used to sort
712685
// CGUs largest to smallest. This would lead to better thread utilization
713686
// by, for example, preventing a large CGU from being processed last and
@@ -823,6 +796,35 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
823796
}
824797
}
825798

799+
// Codegen an allocator shim, if necessary.
800+
// Do this last to ensure the LLVM_passes timer doesn't start while no CGUs have been codegened
801+
// yet for the backend to optimize.
802+
if let Some(kind) = allocator_kind_for_codegen(tcx) {
803+
let llmod_id =
804+
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
805+
let module_llvm = tcx.sess.time("write_allocator_module", || {
806+
backend.codegen_allocator(
807+
tcx,
808+
&llmod_id,
809+
kind,
810+
// If allocator_kind is Some then alloc_error_handler_kind must
811+
// also be Some.
812+
tcx.alloc_error_handler_kind(()).unwrap(),
813+
)
814+
});
815+
816+
ongoing_codegen.wait_for_signal_to_codegen_item();
817+
ongoing_codegen.check_for_errors(tcx.sess);
818+
819+
// These modules are generally cheap and won't throw off scheduling.
820+
let cost = 0;
821+
submit_codegened_module_to_llvm(
822+
&ongoing_codegen.coordinator,
823+
ModuleCodegen::new_allocator(llmod_id, module_llvm),
824+
cost,
825+
);
826+
}
827+
826828
ongoing_codegen.codegen_finished(tcx);
827829

828830
// Since the main thread is sometimes blocked during codegen, we keep track

0 commit comments

Comments
 (0)