diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2020-10-11 13:40:16 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2020-11-12 17:07:02 +0100 |
| commit | db8fa0edfa055b680fa49e8e8e0a6bd118934359 (patch) | |
| tree | 7d417ba8659a14edde0d48837351853e9d221e4b | |
| parent | 0a4f37c1faa0deca1c35bf276f0b7d9bfa811d81 (diff) | |
| download | rust-db8fa0edfa055b680fa49e8e8e0a6bd118934359.tar.gz rust-db8fa0edfa055b680fa49e8e8e0a6bd118934359.zip | |
Inline codegen_mono_items and outline predefine_mono_items
| -rw-r--r-- | src/driver/aot.rs | 6 | ||||
| -rw-r--r-- | src/driver/jit.rs | 6 | ||||
| -rw-r--r-- | src/driver/mod.rs | 13 |
3 files changed, 14 insertions, 11 deletions
diff --git a/src/driver/aot.rs b/src/driver/aot.rs index ff0b994c9a9..f4e8f910d24 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -145,7 +145,11 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege } let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); - super::codegen_mono_items(&mut cx, mono_items); + super::predefine_mono_items(&mut cx, &mono_items); + for (mono_item, (linkage, visibility)) in mono_items { + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + super::codegen_mono_item(&mut cx, mono_item, linkage); + } let (mut module, global_asm, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context, false); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 07f092e212f..5a844841c2c 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -70,7 +70,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let (mut jit_module, global_asm, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { - super::codegen_mono_items(&mut cx, mono_items); + super::predefine_mono_items(&mut cx, &mono_items); + for (mono_item, (linkage, visibility)) in mono_items { + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + super::codegen_mono_item(&mut cx, mono_item, linkage); + } tcx.sess.time("finalize CodegenCx", || cx.finalize()) }); if !global_asm.is_empty() { diff --git a/src/driver/mod.rs b/src/driver/mod.rs index a11dc57ee64..4aed353eb1c 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,4 +1,4 @@ -//! Drivers are responsible for calling [`codegen_mono_items`] and performing any further actions +//! Drivers are responsible for calling [`codegen_mono_item`] and performing any further actions //! like JIT executing or writing object files. use std::any::Any; @@ -40,12 +40,12 @@ pub(crate) fn codegen_crate( aot::run_aot(tcx, metadata, need_metadata_module) } -fn codegen_mono_items<'tcx>( +fn predefine_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Module>, - mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, + mono_items: &[(MonoItem<'tcx>, (RLinkage, Visibility))], ) { cx.tcx.sess.time("predefine functions", || { - for &(mono_item, (linkage, visibility)) in &mono_items { + for &(mono_item, (linkage, visibility)) in mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = get_function_name_and_sig( @@ -61,11 +61,6 @@ fn codegen_mono_items<'tcx>( } } }); - - for (mono_item, (linkage, visibility)) in mono_items { - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - codegen_mono_item(cx, mono_item, linkage); - } } fn codegen_mono_item<'tcx, M: Module>( |
