]> git.lizzy.rs Git - rust.git/commitdiff
Inline codegen_cgus
authorbjorn3 <bjorn3@users.noreply.github.com>
Sat, 7 Mar 2020 10:54:35 +0000 (11:54 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Sat, 7 Mar 2020 10:54:35 +0000 (11:54 +0100)
src/driver.rs

index 056fc57989f6907185a8b5a1d0b1985512f1d03e..9d68fb067753b51e7341512b852f975072f3fd84 100644 (file)
@@ -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::<FxHashMap<_, (_, _)>>();
+
+    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 emit_module<B: Backend>(
             }
         };
 
+    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::<FxHashMap<_, (_, _)>>();
+
     let mut module = new_module("some_file".to_string());
 
     let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None {
@@ -208,7 +224,8 @@ fn emit_module<B: Backend>(
         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 emit_module<B: Backend>(
     })
 }
 
-fn codegen_cgus<'tcx>(
-    tcx: TyCtxt<'tcx>,
-    module: &mut Module<impl Backend + 'static>,
-    debug: &mut Option<DebugContext<'tcx>>,
-) {
-    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::<FxHashMap<_, (_, _)>>();
-
-    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<impl Backend + 'static>,