Skip to content

Commit 318318e

Browse files
committed
Extract emit_allocator_module
1 parent a95c269 commit 318318e

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/driver/aot.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,29 @@ pub(crate) fn run_aot(
658658
modules
659659
});
660660

661+
let allocator_module = emit_allocator_module(tcx, &backend_config);
662+
663+
let metadata_module =
664+
if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None };
665+
666+
Box::new(OngoingCodegen {
667+
modules,
668+
allocator_module,
669+
metadata_module,
670+
metadata,
671+
crate_info: CrateInfo::new(tcx, target_cpu),
672+
concurrency_limiter: concurrency_limiter.0,
673+
})
674+
}
675+
676+
fn emit_allocator_module(
677+
tcx: TyCtxt<'_>,
678+
backend_config: &BackendConfig,
679+
) -> Option<CompiledModule> {
661680
let mut allocator_module = make_module(tcx.sess, &backend_config, "allocator_shim".to_string());
662681
let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module);
663682

664-
let allocator_module = if created_alloc_shim {
683+
if created_alloc_shim {
665684
let product = allocator_module.finish();
666685

667686
match emit_module(
@@ -677,19 +696,7 @@ pub(crate) fn run_aot(
677696
}
678697
} else {
679698
None
680-
};
681-
682-
let metadata_module =
683-
if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None };
684-
685-
Box::new(OngoingCodegen {
686-
modules,
687-
allocator_module,
688-
metadata_module,
689-
metadata,
690-
crate_info: CrateInfo::new(tcx, target_cpu),
691-
concurrency_limiter: concurrency_limiter.0,
692-
})
699+
}
693700
}
694701

695702
fn emit_metadata_module(tcx: TyCtxt<'_>, metadata: &EncodedMetadata) -> CompiledModule {

0 commit comments

Comments
 (0)