]> git.lizzy.rs Git - rust.git/commitdiff
Use generic_activity_with_arg in codegen_fn and compile_fn
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>
Fri, 3 Feb 2023 17:33:39 +0000 (17:33 +0000)
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>
Fri, 3 Feb 2023 17:33:39 +0000 (17:33 +0000)
src/base.rs
src/driver/aot.rs

index 184ddbdd28063cb53c4c4d115e990f52819f59de..b43bb5e8668d6bc7766dc7e997b0e4d7deef922d 100644 (file)
@@ -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
index 2aa3209e2b158ed22fc70a1da792a2064c1259b1..58b01dfb5b0ec84b25600137467fbe733ca1fe51 100644 (file)
@@ -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)