@@ -128,15 +128,13 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
128128 MonoItem :: Fn ( inst) => match backend_config. codegen_mode {
129129 CodegenMode :: Aot => unreachable ! ( ) ,
130130 CodegenMode :: Jit => {
131- tcx. sess . time ( "codegen fn" , || {
132- crate :: base:: codegen_and_compile_fn (
133- tcx,
134- & mut cx,
135- & mut cached_context,
136- & mut jit_module,
137- inst,
138- )
139- } ) ;
131+ codegen_and_compile_fn (
132+ tcx,
133+ & mut cx,
134+ & mut cached_context,
135+ & mut jit_module,
136+ inst,
137+ ) ;
140138 }
141139 CodegenMode :: JitLazy => {
142140 codegen_shim ( tcx, & mut cx, & mut cached_context, & mut jit_module, inst)
@@ -219,6 +217,24 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
219217 }
220218}
221219
220+ pub ( crate ) fn codegen_and_compile_fn < ' tcx > (
221+ tcx : TyCtxt < ' tcx > ,
222+ cx : & mut crate :: CodegenCx ,
223+ cached_context : & mut Context ,
224+ module : & mut dyn Module ,
225+ instance : Instance < ' tcx > ,
226+ ) {
227+ tcx. sess . time ( "codegen and compile fn" , || {
228+ let _inst_guard =
229+ crate :: PrintOnPanic ( || format ! ( "{:?} {}" , instance, tcx. symbol_name( instance) . name) ) ;
230+
231+ let cached_func = std:: mem:: replace ( & mut cached_context. func , Function :: new ( ) ) ;
232+ let codegened_func = crate :: base:: codegen_fn ( tcx, cx, cached_func, module, instance) ;
233+
234+ crate :: base:: compile_fn ( cx, cached_context, module, codegened_func) ;
235+ } ) ;
236+ }
237+
222238extern "C" fn clif_jit_fn (
223239 instance_ptr : * const Instance < ' static > ,
224240 trampoline_ptr : * const u8 ,
@@ -271,15 +287,7 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
271287 false ,
272288 Symbol :: intern ( "dummy_cgu_name" ) ,
273289 ) ;
274- tcx. sess . time ( "codegen fn" , || {
275- crate :: base:: codegen_and_compile_fn (
276- tcx,
277- & mut cx,
278- & mut Context :: new ( ) ,
279- jit_module,
280- instance,
281- )
282- } ) ;
290+ codegen_and_compile_fn ( tcx, & mut cx, & mut Context :: new ( ) , jit_module, instance) ;
283291
284292 assert ! ( cx. global_asm. is_empty( ) ) ;
285293 jit_module. finalize_definitions ( ) . unwrap ( ) ;
0 commit comments