Skip to content

Commit df1b251

Browse files
committed
Remove TyCtxt parameter from compile_fn
1 parent c820b7c commit df1b251

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/base.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
3636
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
3737
let codegened_func = codegen_fn(tcx, cx, cached_func, module, instance);
3838

39-
compile_fn(tcx, cx, cached_context, module, codegened_func);
39+
compile_fn(cx, cached_context, module, codegened_func);
4040
}
4141

4242
fn codegen_fn<'tcx>(
@@ -142,7 +142,6 @@ fn codegen_fn<'tcx>(
142142
}
143143

144144
fn compile_fn<'tcx>(
145-
tcx: TyCtxt<'tcx>,
146145
cx: &mut crate::CodegenCx<'tcx>,
147146
cached_context: &mut Context,
148147
module: &mut dyn Module,
@@ -193,7 +192,7 @@ fn compile_fn<'tcx>(
193192
};
194193

195194
// Define function
196-
tcx.sess.time("define function", || {
195+
cx.profiler.verbose_generic_activity("define function").run(|| {
197196
context.want_disasm = cx.should_write_ir;
198197
module.define_function(codegened_func.func_id, context).unwrap();
199198
});
@@ -222,7 +221,7 @@ fn compile_fn<'tcx>(
222221
let isa = module.isa();
223222
let debug_context = &mut cx.debug_context;
224223
let unwind_context = &mut cx.unwind_context;
225-
tcx.sess.time("generate debug info", || {
224+
cx.profiler.verbose_generic_activity("generate debug info").run(|| {
226225
if let Some(debug_context) = debug_context {
227226
debug_context.define_function(
228227
codegened_func.instance,

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use std::sync::Arc;
3030

3131
use rustc_codegen_ssa::traits::CodegenBackend;
3232
use rustc_codegen_ssa::CodegenResults;
33+
use rustc_data_structures::profiling::SelfProfilerRef;
3334
use rustc_errors::ErrorGuaranteed;
3435
use rustc_metadata::EncodedMetadata;
3536
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
@@ -122,6 +123,7 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
122123
/// The codegen context holds any information shared between the codegen of individual functions
123124
/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
124125
struct CodegenCx<'tcx> {
126+
profiler: SelfProfilerRef,
125127
output_filenames: Arc<OutputFilenames>,
126128
should_write_ir: bool,
127129
global_asm: String,
@@ -149,6 +151,7 @@ impl<'tcx> CodegenCx<'tcx> {
149151
None
150152
};
151153
CodegenCx {
154+
profiler: tcx.prof.clone(),
152155
output_filenames: tcx.output_filenames(()).clone(),
153156
should_write_ir: crate::pretty_clif::should_write_ir(tcx),
154157
global_asm: String::new(),

0 commit comments

Comments
 (0)