about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-08-17 13:47:52 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-08-17 13:47:52 +0000
commitdf1b25171c8b2b209d1c667ea8a2e41a81c108f2 (patch)
tree0dd2e08bacf40bb3901525348e80094e4ed866c1
parentc820b7cd607cd2fa7eec88785d92d10461b39053 (diff)
downloadrust-df1b25171c8b2b209d1c667ea8a2e41a81c108f2.tar.gz
rust-df1b25171c8b2b209d1c667ea8a2e41a81c108f2.zip
Remove TyCtxt parameter from compile_fn
-rw-r--r--src/base.rs7
-rw-r--r--src/lib.rs3
2 files changed, 6 insertions, 4 deletions
diff --git a/src/base.rs b/src/base.rs
index 6a276df40ba..a7c7f66e166 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -36,7 +36,7 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
     let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
     let codegened_func = codegen_fn(tcx, cx, cached_func, module, instance);
 
-    compile_fn(tcx, cx, cached_context, module, codegened_func);
+    compile_fn(cx, cached_context, module, codegened_func);
 }
 
 fn codegen_fn<'tcx>(
@@ -142,7 +142,6 @@ fn codegen_fn<'tcx>(
 }
 
 fn compile_fn<'tcx>(
-    tcx: TyCtxt<'tcx>,
     cx: &mut crate::CodegenCx<'tcx>,
     cached_context: &mut Context,
     module: &mut dyn Module,
@@ -193,7 +192,7 @@ fn compile_fn<'tcx>(
     };
 
     // Define function
-    tcx.sess.time("define function", || {
+    cx.profiler.verbose_generic_activity("define function").run(|| {
         context.want_disasm = cx.should_write_ir;
         module.define_function(codegened_func.func_id, context).unwrap();
     });
@@ -222,7 +221,7 @@ fn compile_fn<'tcx>(
     let isa = module.isa();
     let debug_context = &mut cx.debug_context;
     let unwind_context = &mut cx.unwind_context;
-    tcx.sess.time("generate debug info", || {
+    cx.profiler.verbose_generic_activity("generate debug info").run(|| {
         if let Some(debug_context) = debug_context {
             debug_context.define_function(
                 codegened_func.instance,
diff --git a/src/lib.rs b/src/lib.rs
index 1e851e31ac3..f4ffbbcf86e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -30,6 +30,7 @@ use std::sync::Arc;
 
 use rustc_codegen_ssa::traits::CodegenBackend;
 use rustc_codegen_ssa::CodegenResults;
+use rustc_data_structures::profiling::SelfProfilerRef;
 use rustc_errors::ErrorGuaranteed;
 use rustc_metadata::EncodedMetadata;
 use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
@@ -122,6 +123,7 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
 /// The codegen context holds any information shared between the codegen of individual functions
 /// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
 struct CodegenCx<'tcx> {
+    profiler: SelfProfilerRef,
     output_filenames: Arc<OutputFilenames>,
     should_write_ir: bool,
     global_asm: String,
@@ -149,6 +151,7 @@ impl<'tcx> CodegenCx<'tcx> {
             None
         };
         CodegenCx {
+            profiler: tcx.prof.clone(),
             output_filenames: tcx.output_filenames(()).clone(),
             should_write_ir: crate::pretty_clif::should_write_ir(tcx),
             global_asm: String::new(),