]> git.lizzy.rs Git - rust.git/blobdiff - src/main_shim.rs
Rollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3
[rust.git] / src / main_shim.rs
index 520a54b8e53338380e8bffaf5bb88c873ea9528b..b193cea877dad493996c9bbee8cf1a1011345bc3 100644 (file)
@@ -7,8 +7,9 @@
 /// users main function.
 pub(crate) fn maybe_create_entry_wrapper(
     tcx: TyCtxt<'_>,
-    module: &mut Module<impl Backend + 'static>,
+    module: &mut impl Module,
     unwind_context: &mut UnwindContext<'_>,
+    use_jit: bool,
 ) {
     let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) {
         Some((def_id, entry_ty)) => (
@@ -32,14 +33,16 @@ pub(crate) fn maybe_create_entry_wrapper(
         unwind_context,
         main_def_id,
         use_start_lang_item,
+        use_jit,
     );
 
     fn create_entry_fn(
         tcx: TyCtxt<'_>,
-        m: &mut Module<impl Backend + 'static>,
+        m: &mut impl Module,
         unwind_context: &mut UnwindContext<'_>,
         rust_main_def_id: DefId,
         use_start_lang_item: bool,
+        use_jit: bool,
     ) {
         let main_ret_ty = tcx.fn_sig(rust_main_def_id).output();
         // Given that `main()` has no arguments,
@@ -47,7 +50,7 @@ fn create_entry_fn(
         // late-bound regions, since late-bound
         // regions must appear in the argument
         // listing.
-        let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_bound_vars().unwrap());
+        let main_ret_ty = tcx.erase_regions(main_ret_ty.no_bound_vars().unwrap());
 
         let cmain_sig = Signature {
             params: vec![
@@ -66,14 +69,14 @@ fn create_entry_fn(
 
         let instance = Instance::mono(tcx, rust_main_def_id).polymorphize(tcx);
 
-        let (main_name, main_sig) =
-            get_function_name_and_sig(tcx, m.isa().triple(), instance, false);
+        let main_name = tcx.symbol_name(instance).name.to_string();
+        let main_sig = get_function_sig(tcx, m.isa().triple(), instance);
         let main_func_id = m
             .declare_function(&main_name, Linkage::Import, &main_sig)
             .unwrap();
 
         let mut ctx = Context::new();
-        ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone());
+        ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig);
         {
             let mut func_ctx = FunctionBuilderContext::new();
             let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
@@ -83,7 +86,7 @@ fn create_entry_fn(
             let arg_argc = bcx.append_block_param(block, m.target_config().pointer_type());
             let arg_argv = bcx.append_block_param(block, m.target_config().pointer_type());
 
-            crate::atomic_shim::init_global_lock(m, &mut bcx);
+            crate::atomic_shim::init_global_lock(m, &mut bcx, use_jit);
 
             let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func);