diff --git a/src/base.rs b/src/base.rs index 184ddbdd2806..b43bb5e8668d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -30,6 +30,9 @@ pub(crate) fn codegen_fn<'tcx>( ) -> CodegenedFunction { debug_assert!(!instance.substs.needs_infer()); + let symbol_name = tcx.symbol_name(instance).name.to_string(); + let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name); + let mir = tcx.instance_mir(instance.def); let _mir_guard = crate::PrintOnPanic(|| { let mut buf = Vec::new(); @@ -41,7 +44,6 @@ pub(crate) fn codegen_fn<'tcx>( }); // Declare function - let symbol_name = tcx.symbol_name(instance).name.to_string(); let sig = get_function_sig(tcx, module.target_config().default_call_conv, instance); let func_id = module.declare_function(&symbol_name, Linkage::Local, &sig).unwrap(); @@ -129,6 +131,9 @@ pub(crate) fn compile_fn( module: &mut dyn Module, codegened_func: CodegenedFunction, ) { + let _timer = + cx.profiler.generic_activity_with_arg("compile function", &*codegened_func.symbol_name); + let clif_comments = codegened_func.clif_comments; // Store function in context diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 2aa3209e2b15..58b01dfb5b0e 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -291,16 +291,14 @@ fn module_codegen( for (mono_item, _) in mono_items { match mono_item { MonoItem::Fn(inst) => { - tcx.prof.generic_activity("codegen fn").run(|| { - let codegened_function = crate::base::codegen_fn( - tcx, - &mut cx, - Function::new(), - &mut module, - inst, - ); - codegened_functions.push(codegened_function); - }); + let codegened_function = crate::base::codegen_fn( + tcx, + &mut cx, + Function::new(), + &mut module, + inst, + ); + codegened_functions.push(codegened_function); } MonoItem::Static(def_id) => { crate::constant::codegen_static(tcx, &mut module, def_id)