From 2ecffb6fc42fb5f2fce0ac0620176c5924d69dd6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:54:35 +0100 Subject: [PATCH] Inline codegen_cgus --- src/driver.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 056fc57989f..9d68fb06775 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -67,8 +67,17 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .declare_function("main", Linkage::Import, &sig) .unwrap(); - codegen_cgus(tcx, &mut jit_module, &mut None); + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); + + codegen_mono_items(tcx, &mut jit_module, None, mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); crate::allocator::codegen(tcx, &mut jit_module); + jit_module.finalize_definitions(); tcx.sess.abort_if_errors(); @@ -196,6 +205,13 @@ fn run_aot( } }; + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); + let mut module = new_module("some_file".to_string()); let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { @@ -208,7 +224,8 @@ fn run_aot( None }; - codegen_cgus(tcx, &mut module, &mut debug); + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); tcx.sess.abort_if_errors(); @@ -283,23 +300,6 @@ fn run_aot( }) } -fn codegen_cgus<'tcx>( - tcx: TyCtxt<'tcx>, - module: &mut Module, - debug: &mut Option>, -) { - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>(); - - codegen_mono_items(tcx, module, debug.as_mut(), mono_items); - - crate::main_shim::maybe_create_entry_wrapper(tcx, module); -} - fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module,