Include allocator module in LLVM_passes timer
This commit is contained in:
@@ -110,7 +110,6 @@ pub struct ModuleConfig {
|
||||
pub lint_llvm_ir: bool,
|
||||
pub no_prepopulate_passes: bool,
|
||||
pub no_builtins: bool,
|
||||
pub time_module: bool,
|
||||
pub vectorize_loop: bool,
|
||||
pub vectorize_slp: bool,
|
||||
pub merge_functions: bool,
|
||||
@@ -228,10 +227,6 @@ impl ModuleConfig {
|
||||
no_prepopulate_passes: sess.opts.cg.no_prepopulate_passes,
|
||||
no_builtins: no_builtins || sess.target.no_builtins,
|
||||
|
||||
// Exclude metadata and allocator modules from time_passes output,
|
||||
// since they throw off the "LLVM passes" measurement.
|
||||
time_module: if_regular!(true, false),
|
||||
|
||||
// Copy what clang does by turning on loop vectorization at O2 and
|
||||
// slp vectorization at O3.
|
||||
vectorize_loop: !sess.opts.cg.no_vectorize_loops
|
||||
@@ -1740,7 +1735,7 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
|
||||
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
|
||||
work: WorkItem<B>,
|
||||
) {
|
||||
if cgcx.config(work.module_kind()).time_module && llvm_start_time.is_none() {
|
||||
if llvm_start_time.is_none() {
|
||||
*llvm_start_time = Some(cgcx.prof.verbose_generic_activity("LLVM_passes"));
|
||||
}
|
||||
|
||||
|
||||
@@ -681,33 +681,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
|
||||
let ongoing_codegen = start_async_codegen(backend.clone(), tcx, target_cpu, autodiff_items);
|
||||
|
||||
// Codegen an allocator shim, if necessary.
|
||||
if let Some(kind) = allocator_kind_for_codegen(tcx) {
|
||||
let llmod_id =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
||||
let module_llvm = tcx.sess.time("write_allocator_module", || {
|
||||
backend.codegen_allocator(
|
||||
tcx,
|
||||
&llmod_id,
|
||||
kind,
|
||||
// If allocator_kind is Some then alloc_error_handler_kind must
|
||||
// also be Some.
|
||||
tcx.alloc_error_handler_kind(()).unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
ongoing_codegen.wait_for_signal_to_codegen_item();
|
||||
ongoing_codegen.check_for_errors(tcx.sess);
|
||||
|
||||
// These modules are generally cheap and won't throw off scheduling.
|
||||
let cost = 0;
|
||||
submit_codegened_module_to_llvm(
|
||||
&ongoing_codegen.coordinator,
|
||||
ModuleCodegen::new_allocator(llmod_id, module_llvm),
|
||||
cost,
|
||||
);
|
||||
}
|
||||
|
||||
// For better throughput during parallel processing by LLVM, we used to sort
|
||||
// CGUs largest to smallest. This would lead to better thread utilization
|
||||
// by, for example, preventing a large CGU from being processed last and
|
||||
@@ -823,6 +796,35 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
}
|
||||
}
|
||||
|
||||
// Codegen an allocator shim, if necessary.
|
||||
// Do this last to ensure the LLVM_passes timer doesn't start while no CGUs have been codegened
|
||||
// yet for the backend to optimize.
|
||||
if let Some(kind) = allocator_kind_for_codegen(tcx) {
|
||||
let llmod_id =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
||||
let module_llvm = tcx.sess.time("write_allocator_module", || {
|
||||
backend.codegen_allocator(
|
||||
tcx,
|
||||
&llmod_id,
|
||||
kind,
|
||||
// If allocator_kind is Some then alloc_error_handler_kind must
|
||||
// also be Some.
|
||||
tcx.alloc_error_handler_kind(()).unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
ongoing_codegen.wait_for_signal_to_codegen_item();
|
||||
ongoing_codegen.check_for_errors(tcx.sess);
|
||||
|
||||
// These modules are generally cheap and won't throw off scheduling.
|
||||
let cost = 0;
|
||||
submit_codegened_module_to_llvm(
|
||||
&ongoing_codegen.coordinator,
|
||||
ModuleCodegen::new_allocator(llmod_id, module_llvm),
|
||||
cost,
|
||||
);
|
||||
}
|
||||
|
||||
ongoing_codegen.codegen_finished(tcx);
|
||||
|
||||
// Since the main thread is sometimes blocked during codegen, we keep track
|
||||
|
||||
Reference in New Issue
Block a user