Skip to content

Commit 469783c

Browse files
committed
Use generic_activity_with_arg in codegen_fn and compile_fn
1 parent d2ffe40 commit 469783c

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/base.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub(crate) fn codegen_fn<'tcx>(
3030
) -> CodegenedFunction {
3131
debug_assert!(!instance.substs.needs_infer());
3232

33+
let symbol_name = tcx.symbol_name(instance).name.to_string();
34+
let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name);
35+
3336
let mir = tcx.instance_mir(instance.def);
3437
let _mir_guard = crate::PrintOnPanic(|| {
3538
let mut buf = Vec::new();
@@ -41,7 +44,6 @@ pub(crate) fn codegen_fn<'tcx>(
4144
});
4245

4346
// Declare function
44-
let symbol_name = tcx.symbol_name(instance).name.to_string();
4547
let sig = get_function_sig(tcx, module.target_config().default_call_conv, instance);
4648
let func_id = module.declare_function(&symbol_name, Linkage::Local, &sig).unwrap();
4749

@@ -129,6 +131,9 @@ pub(crate) fn compile_fn(
129131
module: &mut dyn Module,
130132
codegened_func: CodegenedFunction,
131133
) {
134+
let _timer =
135+
cx.profiler.generic_activity_with_arg("compile function", &*codegened_func.symbol_name);
136+
132137
let clif_comments = codegened_func.clif_comments;
133138

134139
// Store function in context

src/driver/aot.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,14 @@ fn module_codegen(
291291
for (mono_item, _) in mono_items {
292292
match mono_item {
293293
MonoItem::Fn(inst) => {
294-
tcx.prof.generic_activity("codegen fn").run(|| {
295-
let codegened_function = crate::base::codegen_fn(
296-
tcx,
297-
&mut cx,
298-
Function::new(),
299-
&mut module,
300-
inst,
301-
);
302-
codegened_functions.push(codegened_function);
303-
});
294+
let codegened_function = crate::base::codegen_fn(
295+
tcx,
296+
&mut cx,
297+
Function::new(),
298+
&mut module,
299+
inst,
300+
);
301+
codegened_functions.push(codegened_function);
304302
}
305303
MonoItem::Static(def_id) => {
306304
crate::constant::codegen_static(tcx, &mut module, def_id)

0 commit comments

Comments
 (0)