Cleanup -Ztime-passes output
This commit is contained in:
parent
a465d6a860
commit
d2ffe40864
15
src/base.rs
15
src/base.rs
@ -95,7 +95,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||||||
next_ssa_var: 0,
|
next_ssa_var: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
tcx.sess.time("codegen clif ir", || codegen_fn_body(&mut fx, start_block));
|
tcx.prof.generic_activity("codegen clif ir").run(|| codegen_fn_body(&mut fx, start_block));
|
||||||
fx.bcx.seal_all_blocks();
|
fx.bcx.seal_all_blocks();
|
||||||
fx.bcx.finalize();
|
fx.bcx.finalize();
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ pub(crate) fn compile_fn(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Define function
|
// Define function
|
||||||
cx.profiler.verbose_generic_activity("define function").run(|| {
|
cx.profiler.generic_activity("define function").run(|| {
|
||||||
context.want_disasm = cx.should_write_ir;
|
context.want_disasm = cx.should_write_ir;
|
||||||
module.define_function(codegened_func.func_id, context).unwrap();
|
module.define_function(codegened_func.func_id, context).unwrap();
|
||||||
});
|
});
|
||||||
@ -203,7 +203,7 @@ pub(crate) fn compile_fn(
|
|||||||
let isa = module.isa();
|
let isa = module.isa();
|
||||||
let debug_context = &mut cx.debug_context;
|
let debug_context = &mut cx.debug_context;
|
||||||
let unwind_context = &mut cx.unwind_context;
|
let unwind_context = &mut cx.unwind_context;
|
||||||
cx.profiler.verbose_generic_activity("generate debug info").run(|| {
|
cx.profiler.generic_activity("generate debug info").run(|| {
|
||||||
if let Some(debug_context) = debug_context {
|
if let Some(debug_context) = debug_context {
|
||||||
codegened_func.func_debug_cx.unwrap().finalize(
|
codegened_func.func_debug_cx.unwrap().finalize(
|
||||||
debug_context,
|
debug_context,
|
||||||
@ -220,7 +220,7 @@ pub(crate) fn verify_func(
|
|||||||
writer: &crate::pretty_clif::CommentWriter,
|
writer: &crate::pretty_clif::CommentWriter,
|
||||||
func: &Function,
|
func: &Function,
|
||||||
) {
|
) {
|
||||||
tcx.sess.time("verify clif ir", || {
|
tcx.prof.generic_activity("verify clif ir").run(|| {
|
||||||
let flags = cranelift_codegen::settings::Flags::new(cranelift_codegen::settings::builder());
|
let flags = cranelift_codegen::settings::Flags::new(cranelift_codegen::settings::builder());
|
||||||
match cranelift_codegen::verify_function(&func, &flags) {
|
match cranelift_codegen::verify_function(&func, &flags) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
@ -256,7 +256,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fx.tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(fx, start_block));
|
fx.tcx
|
||||||
|
.prof
|
||||||
|
.generic_activity("codegen prelude")
|
||||||
|
.run(|| crate::abi::codegen_fn_prelude(fx, start_block));
|
||||||
|
|
||||||
for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() {
|
for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() {
|
||||||
let block = fx.get_block(bb);
|
let block = fx.get_block(bb);
|
||||||
@ -417,7 +420,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||||||
cleanup: _,
|
cleanup: _,
|
||||||
from_hir_call: _,
|
from_hir_call: _,
|
||||||
} => {
|
} => {
|
||||||
fx.tcx.sess.time("codegen call", || {
|
fx.tcx.prof.generic_activity("codegen call").run(|| {
|
||||||
crate::abi::codegen_terminator_call(
|
crate::abi::codegen_terminator_call(
|
||||||
fx,
|
fx,
|
||||||
mir::SourceInfo { span: *fn_span, ..source_info },
|
mir::SourceInfo { span: *fn_span, ..source_info },
|
||||||
|
@ -42,12 +42,6 @@ pub struct BackendConfig {
|
|||||||
/// Defaults to the value of `CG_CLIF_JIT_ARGS`.
|
/// Defaults to the value of `CG_CLIF_JIT_ARGS`.
|
||||||
pub jit_args: Vec<String>,
|
pub jit_args: Vec<String>,
|
||||||
|
|
||||||
/// Display the time it took to perform codegen for a crate.
|
|
||||||
///
|
|
||||||
/// Defaults to true when the `CG_CLIF_DISPLAY_CG_TIME` env var is set to 1 or false otherwise.
|
|
||||||
/// Can be set using `-Cllvm-args=display_cg_time=...`.
|
|
||||||
pub display_cg_time: bool,
|
|
||||||
|
|
||||||
/// Enable the Cranelift ir verifier for all compilation passes. If not set it will only run
|
/// Enable the Cranelift ir verifier for all compilation passes. If not set it will only run
|
||||||
/// once before passing the clif ir to Cranelift for compilation.
|
/// once before passing the clif ir to Cranelift for compilation.
|
||||||
///
|
///
|
||||||
@ -73,7 +67,6 @@ impl Default for BackendConfig {
|
|||||||
let args = std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new());
|
let args = std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new());
|
||||||
args.split(' ').map(|arg| arg.to_string()).collect()
|
args.split(' ').map(|arg| arg.to_string()).collect()
|
||||||
},
|
},
|
||||||
display_cg_time: bool_env_var("CG_CLIF_DISPLAY_CG_TIME"),
|
|
||||||
enable_verifier: cfg!(debug_assertions) || bool_env_var("CG_CLIF_ENABLE_VERIFIER"),
|
enable_verifier: cfg!(debug_assertions) || bool_env_var("CG_CLIF_ENABLE_VERIFIER"),
|
||||||
disable_incr_cache: bool_env_var("CG_CLIF_DISABLE_INCR_CACHE"),
|
disable_incr_cache: bool_env_var("CG_CLIF_DISABLE_INCR_CACHE"),
|
||||||
}
|
}
|
||||||
@ -92,7 +85,6 @@ impl BackendConfig {
|
|||||||
if let Some((name, value)) = opt.split_once('=') {
|
if let Some((name, value)) = opt.split_once('=') {
|
||||||
match name {
|
match name {
|
||||||
"mode" => config.codegen_mode = value.parse()?,
|
"mode" => config.codegen_mode = value.parse()?,
|
||||||
"display_cg_time" => config.display_cg_time = parse_bool(name, value)?,
|
|
||||||
"enable_verifier" => config.enable_verifier = parse_bool(name, value)?,
|
"enable_verifier" => config.enable_verifier = parse_bool(name, value)?,
|
||||||
"disable_incr_cache" => config.disable_incr_cache = parse_bool(name, value)?,
|
"disable_incr_cache" => config.disable_incr_cache = parse_bool(name, value)?,
|
||||||
_ => return Err(format!("Unknown option `{}`", name)),
|
_ => return Err(format!("Unknown option `{}`", name)),
|
||||||
|
@ -272,7 +272,8 @@ fn module_codegen(
|
|||||||
ConcurrencyLimiterToken,
|
ConcurrencyLimiterToken,
|
||||||
),
|
),
|
||||||
) -> OngoingModuleCodegen {
|
) -> OngoingModuleCodegen {
|
||||||
let (cgu_name, mut cx, mut module, codegened_functions) = tcx.sess.time("codegen cgu", || {
|
let (cgu_name, mut cx, mut module, codegened_functions) =
|
||||||
|
tcx.prof.verbose_generic_activity_with_arg("codegen cgu", cgu_name.as_str()).run(|| {
|
||||||
let cgu = tcx.codegen_unit(cgu_name);
|
let cgu = tcx.codegen_unit(cgu_name);
|
||||||
let mono_items = cgu.items_in_deterministic_order(tcx);
|
let mono_items = cgu.items_in_deterministic_order(tcx);
|
||||||
|
|
||||||
@ -290,7 +291,7 @@ fn module_codegen(
|
|||||||
for (mono_item, _) in mono_items {
|
for (mono_item, _) in mono_items {
|
||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(inst) => {
|
MonoItem::Fn(inst) => {
|
||||||
tcx.sess.time("codegen fn", || {
|
tcx.prof.generic_activity("codegen fn").run(|| {
|
||||||
let codegened_function = crate::base::codegen_fn(
|
let codegened_function = crate::base::codegen_fn(
|
||||||
tcx,
|
tcx,
|
||||||
&mut cx,
|
&mut cx,
|
||||||
@ -305,7 +306,11 @@ fn module_codegen(
|
|||||||
crate::constant::codegen_static(tcx, &mut module, def_id)
|
crate::constant::codegen_static(tcx, &mut module, def_id)
|
||||||
}
|
}
|
||||||
MonoItem::GlobalAsm(item_id) => {
|
MonoItem::GlobalAsm(item_id) => {
|
||||||
crate::global_asm::codegen_global_asm_item(tcx, &mut cx.global_asm, item_id);
|
crate::global_asm::codegen_global_asm_item(
|
||||||
|
tcx,
|
||||||
|
&mut cx.global_asm,
|
||||||
|
item_id,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,19 +328,31 @@ fn module_codegen(
|
|||||||
});
|
});
|
||||||
|
|
||||||
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
||||||
cx.profiler.clone().verbose_generic_activity("compile functions").run(|| {
|
cx.profiler.clone().verbose_generic_activity_with_arg("compile functions", &*cgu_name).run(
|
||||||
|
|| {
|
||||||
let mut cached_context = Context::new();
|
let mut cached_context = Context::new();
|
||||||
for codegened_func in codegened_functions {
|
for codegened_func in codegened_functions {
|
||||||
crate::base::compile_fn(&mut cx, &mut cached_context, &mut module, codegened_func);
|
crate::base::compile_fn(
|
||||||
|
&mut cx,
|
||||||
|
&mut cached_context,
|
||||||
|
&mut module,
|
||||||
|
codegened_func,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let global_asm_object_file =
|
let global_asm_object_file = cx
|
||||||
cx.profiler.verbose_generic_activity("compile assembly").run(|| {
|
.profiler
|
||||||
|
.verbose_generic_activity_with_arg("compile assembly", &*cgu_name)
|
||||||
|
.run(|| {
|
||||||
crate::global_asm::compile_global_asm(&global_asm_config, &cgu_name, &cx.global_asm)
|
crate::global_asm::compile_global_asm(&global_asm_config, &cgu_name, &cx.global_asm)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let codegen_result = cx.profiler.verbose_generic_activity("write object file").run(|| {
|
let codegen_result = cx
|
||||||
|
.profiler
|
||||||
|
.verbose_generic_activity_with_arg("write object file", &*cgu_name)
|
||||||
|
.run(|| {
|
||||||
emit_cgu(
|
emit_cgu(
|
||||||
&global_asm_config.output_filenames,
|
&global_asm_config.output_filenames,
|
||||||
&cx.profiler,
|
&cx.profiler,
|
||||||
@ -375,7 +392,7 @@ pub(crate) fn run_aot(
|
|||||||
|
|
||||||
let mut concurrency_limiter = ConcurrencyLimiter::new(tcx.sess, cgus.len());
|
let mut concurrency_limiter = ConcurrencyLimiter::new(tcx.sess, cgus.len());
|
||||||
|
|
||||||
let modules = super::time(tcx, backend_config.display_cg_time, "codegen mono items", || {
|
let modules = tcx.sess.time("codegen mono items", || {
|
||||||
cgus.iter()
|
cgus.iter()
|
||||||
.map(|cgu| {
|
.map(|cgu| {
|
||||||
let cgu_reuse = if backend_config.disable_incr_cache {
|
let cgu_reuse = if backend_config.disable_incr_cache {
|
||||||
@ -437,7 +454,6 @@ pub(crate) fn run_aot(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let metadata_module = if need_metadata_module {
|
let metadata_module = if need_metadata_module {
|
||||||
let _timer = tcx.prof.generic_activity("codegen crate metadata");
|
|
||||||
let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || {
|
let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || {
|
||||||
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
|
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<Vec<(_, (_, _))>>();
|
.collect::<Vec<(_, (_, _))>>();
|
||||||
|
|
||||||
super::time(tcx, backend_config.display_cg_time, "codegen mono items", || {
|
tcx.sess.time("codegen mono items", || {
|
||||||
super::predefine_mono_items(tcx, &mut jit_module, &mono_items);
|
super::predefine_mono_items(tcx, &mut jit_module, &mono_items);
|
||||||
for (mono_item, _) in mono_items {
|
for (mono_item, _) in mono_items {
|
||||||
match mono_item {
|
match mono_item {
|
||||||
@ -224,7 +224,7 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
|||||||
module: &mut dyn Module,
|
module: &mut dyn Module,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) {
|
) {
|
||||||
tcx.sess.time("codegen and compile fn", || {
|
tcx.prof.generic_activity("codegen and compile fn").run(|| {
|
||||||
let _inst_guard =
|
let _inst_guard =
|
||||||
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ fn predefine_mono_items<'tcx>(
|
|||||||
module: &mut dyn Module,
|
module: &mut dyn Module,
|
||||||
mono_items: &[(MonoItem<'tcx>, (RLinkage, Visibility))],
|
mono_items: &[(MonoItem<'tcx>, (RLinkage, Visibility))],
|
||||||
) {
|
) {
|
||||||
tcx.sess.time("predefine functions", || {
|
tcx.prof.generic_activity("predefine functions").run(|| {
|
||||||
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
|
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
|
||||||
for &(mono_item, (linkage, visibility)) in mono_items {
|
for &(mono_item, (linkage, visibility)) in mono_items {
|
||||||
match mono_item {
|
match mono_item {
|
||||||
@ -39,16 +39,3 @@ fn predefine_mono_items<'tcx>(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn time<R>(tcx: TyCtxt<'_>, display: bool, name: &'static str, f: impl FnOnce() -> R) -> R {
|
|
||||||
if display {
|
|
||||||
println!("[{:<30}: {}] start", tcx.crate_name(LOCAL_CRATE), name);
|
|
||||||
let before = std::time::Instant::now();
|
|
||||||
let res = tcx.sess.time(name, f);
|
|
||||||
let after = std::time::Instant::now();
|
|
||||||
println!("[{:<30}: {}] end time: {:?}", tcx.crate_name(LOCAL_CRATE), name, after - before);
|
|
||||||
res
|
|
||||||
} else {
|
|
||||||
tcx.sess.time(name, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user