@@ -128,15 +128,13 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
128
128
MonoItem :: Fn ( inst) => match backend_config. codegen_mode {
129
129
CodegenMode :: Aot => unreachable ! ( ) ,
130
130
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
+ ) ;
140
138
}
141
139
CodegenMode :: JitLazy => {
142
140
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) -> ! {
219
217
}
220
218
}
221
219
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
+
222
238
extern "C" fn clif_jit_fn (
223
239
instance_ptr : * const Instance < ' static > ,
224
240
trampoline_ptr : * const u8 ,
@@ -271,15 +287,7 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
271
287
false ,
272
288
Symbol :: intern ( "dummy_cgu_name" ) ,
273
289
) ;
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) ;
283
291
284
292
assert ! ( cx. global_asm. is_empty( ) ) ;
285
293
jit_module. finalize_definitions ( ) . unwrap ( ) ;
0 commit comments