Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b09b8b1

Browse files
committed
Re-use Context in codegen_shim
1 parent b4bf4b5 commit b09b8b1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/driver/jit.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,12 @@ fn codegen_shim<'tcx>(cx: &mut CodegenCx<'_, 'tcx>, inst: Instance<'tcx>) {
271271
)
272272
.unwrap();
273273

274-
let mut trampoline = Function::with_name_signature(ExternalName::default(), sig.clone());
274+
cx.cached_context.clear();
275+
let trampoline = &mut cx.cached_context.func;
276+
trampoline.signature = sig.clone();
277+
275278
let mut builder_ctx = FunctionBuilderContext::new();
276-
let mut trampoline_builder = FunctionBuilder::new(&mut trampoline, &mut builder_ctx);
279+
let mut trampoline_builder = FunctionBuilder::new(trampoline, &mut builder_ctx);
277280

278281
let jit_fn = cx.module.declare_func_in_func(jit_fn, trampoline_builder.func);
279282
let sig_ref = trampoline_builder.func.import_signature(sig);
@@ -293,7 +296,7 @@ fn codegen_shim<'tcx>(cx: &mut CodegenCx<'_, 'tcx>, inst: Instance<'tcx>) {
293296
cx.module
294297
.define_function(
295298
func_id,
296-
&mut Context::for_function(trampoline),
299+
&mut cx.cached_context,
297300
&mut NullTrapSink {},
298301
&mut NullStackMapSink {},
299302
)

0 commit comments

Comments
 (0)